Solved

JNI - Problem with perfcounters.h

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

734 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