I have a simple JNI .DLL that I am trying to use in a test Java application. It is a .c
file that consists of a couple functions, with the header generated by javah
. (I am compiling using MinGW btw)
If I compile and link this code with GCC, I can load the .DLL just fine with System.loadLibrary(), and use it. If I compiled it with G++ however, loadLibrary()
will fail with the dreaded "UnsatisfiedLinkError".
This is my GCC line:
gcc -Wl,--add-stdcall-alias -I"C:\Program Files (x86)\Java\jdk1.7.0_45\include" -I"C:\Program Files (x86)\Java\jdk1.7.0_45\include\win32" -shared -o TestJNI.dll TestJNI.c
This is my G++ line:
g++ -Wl,--add-stdcall-alias -I"C:\Program Files (x86)\Java\jdk1.7.0_45\include" -I"C:\Program Files (x86)\Java\jdk1.7.0_45\include\win32" -shared -o TestJNI.dll TestJNI.c
Any thoughts? I am assuming something is different in the way G++ names the functions, but I don't know what...