Reputation: 3
I currently have two libraries I'm trying to load via JNI - libA.so
and libB.so
. Documentation from Oracle leads me to believe that I can simply do:
System.loadLibrary("A");
System.loadLibrary("B");
and then compile and run like so:
java -Djava.library.path="/path/to/libs" -jar myjarfile.jar
However, doing this only appears to load the first library as the second one throws the error:
java.lang.UnsatisfiedLinkError: /path/to/libs/libB.so: libgomp.so.1: cannot open shared object file: No such file or directory
Upon verifying that both libraries were in the path specified by java.library.path
, I swapped the statements i.e.:
System.loadLibrary("B");
System.loadLibrary("A");
and found that the issue is now with loading library A
:
java.lang.UnsatisfiedLinkError: /path/to/libs/libA.so: libgomp.so.1: cannot open shared object file: No such file or directory
leading me to believe that I'm unable to make consecutive loadLibrary
calls for whatever reason. Executing java -XshowSettings:properties
also confirms that I have correctly set java.library.path
to the location of the libraries.
I've attempted to use System.load()
instead:
System.load("/path/to/libs/libA.so");
System.load("/path/to/libs/libB.so");
in addition to setting the environment variable LD_LIBRARY_PATH
but no luck - this gives me the same issue where the first library gets loaded but the second library throws java.lang.UnsatisfiedLinkError
I'm banging my head against the wall - anyone have any ideas?
(note: I don't think it's relevant, but I'm running my code in a docker container built on the ubuntu image)
Upvotes: 0
Views: 468
Reputation: 549
If you read the error fully, you will notice that in both cases it refers to libgomp being missing. It is likely that your shared objects (either of them) depend on it.
Make sure libgomp was properly installed on your platform and try again. Pretty sure it would solve the problem.
Upvotes: 1