9

I have a c++ header file which contains some functions that the c++ code calls. These function should be mapped to corresponding Java functions. So it is a bit like callbacks, but I cannot figure out how to map them in JavaCpp.

So for instance we have a header file:

#ifdef __cplusplus
extern "C" {
#endif

typedef void (*F_ADDDCALLBACK)(uint32_t arg1, uint32_t arg2, int8_t *arg3);
extern F_ADDDCALLBACK m_CB;

void F_RegisterCallbacks(F_ADDDCALLBACK cb);
void F_Init();
void F_SomeOtherFunction(uint32_t arg1, uint8_t *arg2);

#ifdef __cplusplus
}
#endif

When these functions are called from some c++ code, it should in turn call some java code. How do I map this in JavaCpp?

hammer
  • 123
  • 5

1 Answers1

0

First create a java file where you need to define your own functions. then use javah utility which comes with jdk to generate c header files. By including this header files you need to proceed with your c code.

Please refer to JNI (Java Native Interface) for further information.

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Frzaha%2Fjniex.htm

http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/jniTOC.html

rajenpandit
  • 1,265
  • 1
  • 15
  • 21