I'm having some problems loading 2 libs where one depends on another in Linux. Let's say I have 2 libs, libA.so and libB.so, libB.so depends on libA.so (calling functions from it).
I need to load libB.so from Java via JNI and call some native methods from it.
SO what I'm trying to do is:
static {
System.loadLibrary(A);
System.loadLibrary(B);
}
(Both libraries reside in java.library.path).
Under Win32, it works fine - B.dll sees that A.dll is already loaded, and doesn't try to load it itself (using PATH lookup).
While on Linux, it doesn't work. Additional logging shows, that System.loadLibrary(A); executes correctly, and libA.so is getting loaded fine, then, when we I try to load B, it looks for library libA.so in the LD_LIBRARY_PATH, and it fails (both libs are in java.library.path, but NOT in LD_LIBRARY_PATH).
Does someone why does it happen? Is it related to the way Linux runtime linking works?
I see a lot of way to work it around, but first want to understand the bottom line of that.
Thanks, Mikhail