I have a JNI library "lib.so" that has a dependancy on "lib2.so". When I compiled on another platform with lib2.so as static, all was fine, but when compiling dynamically, I get an UnsatisfiedLinkError. In particular, it says "lib.so: undefined symbol: mysymbol_name". I have verified that mysymbol_name is inside of "lib2.so" using the nm tool. I am also loading "lib2.so" to Java before "lib.so".
Java Code:
System.load("/pathto/lib2.so"); // no error
System.load("/pathto/lib.so"); // triggers UnsatisfiedLinkError
C++ compile stage
g++ -c -fPIC {{{.cpp files}}} {{-I,-L directives}} --std=c++11 -Wl,-soname,lib2.so
C++ link stage
g++ {-L,-I directives} -o lib.so {{.o files}} -l:lib2.so
I am inexperienced with compiling and linking for C/C++, so I'm not sure where the error lies. The C++ compiles and links, so that would mean there is an issue with loading it into Java right?
Update: I have checked ldd lib.so and found that lib2.so is not linked.