Solved

JNI - Problem with perfcounters.h

Posted on 2006-06-15
2
651 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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

623 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