Solved

JNI - Problem with perfcounters.h

Posted on 2006-06-15
2
647 Views
Last Modified: 2007-12-19
Following on from here:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_21790438.html

Hi Experts,
My question is:
1)  how can I build a shared library (dll file) with my "JNI" cpp file?
( I have tried many ways to build the dll file (with VS C++, gcc from MinWG, or cynwin))

My cpp file is:

#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include "CpuUsage.h"
#include "SysUsage_SystemInfo.h"



/*
 * Class:    SysUsage_SystemInfo
 * Method:    getProcessCPUPercentage
 * Signature: ()I
 */
 CCpuUsage mCpuUsage;
 struct helper
 {

  helper() {mCpuUsage.GetCpuUsage() ; } // first call
  };

JNIEXPORT jint JNICALL Java_SysUsage_SystemInfo_getProcessCPUPercentage
  (JNIEnv *, jclass)
  {
       jint SysCpuUsage = mCpuUsage.GetCpuUsage();
       return SysCpuUsage;
  }

/*
 * Class:     SysUsage_SystemInfo
 * Method:    getMaxMem
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_SysUsage_SystemInfo_getMaxMem
  (JNIEnv *, jclass)
  {
       jlong reVal = 0;
       return reVal;
  }

/*
 * Class:     SysUsage_SystemInfo
 * Method:    getFreeMem
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_SysUsage_SystemInfo_getFreeMem
  (JNIEnv *, jclass)
  {
       jlong reVal = 0;
       return reVal;
  }

ERROR: 59 errors but similar to the followings: (all about the perfcounters.h)
c:\eclipseworkspace\rmutils\cppsrc\perfcounters.h(20) : error C2061: syntax error : identifier 'PERF_DATA_BLOCK'
        c:\eclipseworkspace\rmutils\cppsrc\perfcounters.h(334) : see reference to class template instantiation             CPerfCounters<T>' being compiled

c:\eclipseworkspace\rmutils\cppsrc\perfcounters.h(222) : error C2535: '__int64 __thiscall CPerfCounters<__int64>::GetCounterValueForProcessID(void)' : member function already defined or declared
        c:\eclipseworkspace\rmutils\cppsrc\perfcounters.h(46) : see declaration of 'GetCounterValueForProcessID'

Thanks
0
Comment
Question by:phongtran72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 16916195
You'll need to

#include <winperf.h> // has the declaration of 'PERF_DATA_BLOCK'

before including your 'perfcounters.h'
0
 

Author Comment

by:phongtran72
ID: 16919367
Hi JKR,
Thanks for your response. It works!

However I cannot build the shared DLL file. Could you (or someone, please) give me instruction how to build DLL using
Visual Studio 2005, PLEASE? (I have not used this IDE for years because I am mainly developing Java applications.)

Thanks in advance.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question