JNI Problem: Works under Windows, fails under Unix (Solaris 8)
Posted on 2004-11-05
I have a C++ program that functions as a wrapper around an existing C library of functions and implements the native method I call from the Java client. This works perfectly under Windows (compiled with Visual C++), but when I moved everything to the Unix platform (Solaris 8) along with the Unix version of the C library of functions, it fails as follows:
I get no errors from the compiler/linker, but when I run, I get one of two results:
--- If I explicitly reference the C library during the compile (with the -l flag), I can not load my own shared object in the Java client. I get "UnsatisfiedLinkError, no cmosubjni in java.library.path."
---If I do _not_ reference the C library during the build, my shared object loads just fine in the Java client, but the first call to a subroutine in the C library results in "relocation error, symbol not found ..." I can, however, call standard C++ subroutines in the standard libraries, because I've inserted printf statements to see what's going on.
This is (from my makefile) the compile statement with the C library explicitly named:
CC -G -I. -I/fmac/dev/res/rmc/c09591/pmt/src/cdu_trustee/build/inc -I/java/include
-I/java/include/solaris CMOSubJNI.cpp -o libcmosubjni.so -L/fmac/dev/res/rmc/
CMOSubJNI is my wrapper class; the C library is named ilbintexcmoln.a I have both an .so file and an .a file version of the C library; I believe these correspond to the .dll and .lib files under Windows, respectively, so I used the .a file under Unix as I used the .lib file under Windows. Just for the heck of it, I also tried the .so file, with the same results.
Again, this works under Windows, therefore the problem must lie with some switch or other that I am not using or using incorrectly during the compile/link.
Any help would be appreciated.