How to map function call from C ++ to Java using JavaCpp?

I have a c++ header file that contains some functions that c++ code calls. These functions must be mapped to the corresponding Java functions. So this is a bit like callbacks, but I can't figure out how to map them in JavaCpp .

So 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++ , it must in turn call some Java code. How to map this in JavaCpp ?

+8
java c ++ javacpp
source share
1 answer

First create a java file where you need to define your own functions. then use the javah utility that comes with jdk to generate the c header files. By including these header files, you need to continue your code c .

For more information, refer to JNI (Java Native Interface).

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

0
source share

All Articles