This content has been marked as final. Show 3 replies
This is just a guess: You can't call C++ directly from java; you have to call C. Typically this is a matter of the linkage you have defined in your h and c files. Look back thorugh this forum and you will find many examples of specifying C linkage.
Thanks for the hint.
The file that contains the functions that are called from JAVA is a C file, although one C++ object is defined and used there so that I can access my C++ classes. That's why I have to compile the file with g++. I wonder how I should call C++ methods from a pure C file since gcc won't be able to compile the references to the C++ classes.
Is there anyone here who has used the JNI to interace JAVA with C++ and can tell me how to do it?
Alright, just to clarify this for any future readers with a similar problem.
The real problem that created the error output had been a missing linkage to stdc++ in my Makefile. I noticed this when doing a "ldd -r" on my shared object.
The thing with calling C++ code can be done through using the Header file generated by "javah -jni", which puts an "extern C" around the function prototypes. If you're using pure C code you do not need to use the header file. It's just there to tell g++ to generate symbols without signature mapping. You obviously cannot use overloaded functions with the JNI.
Now I've still got a "An unexpected exception has been detected in native code outside the VM", but I assume that this is some bug in my shared object.