-
Notifications
You must be signed in to change notification settings - Fork 159
Description
On linux, when loading library outside of normal library paths, the LD_LIBRARY_PATH has to be set - if it isn't, library fails to load.
Example:
Let's say there's a lib at ~/mylib/libmylib.so. Trying to load it with:
MyLib lib = LibraryLoader.create(MyLib.class).failImmediately()
.search("~/mylib")
.load("libmylib.so");
Fails with java.lang.UnsatisfiedLinkError: libmylib.so: cannot open shared object file: No such file or directory.
When the path in which library resides is added to LD_LIBRARY_PATH (by export LD_LIBRARY_PATH=~/mylib), code above loads the library without any problems.
Expected behaviour:
I'd expect LibraryLoader.search(path) to work, without me having to deal with environment variables. Maybe a fix would be as easy as just prepending path from LibraryLoader.search() to LD_LIBRARY_PATH?
Why:
I'm trying to get a project with native libs packaged in a .jar to work. It works by unpacking these native libs into some directory in users home, and then loading them with jnr-ffi. Again I'd hope that LibraryLoader.search(path).load(lib) would just work, without having to fiddle with env variables.
May be related to #129 (paths added via search() seem to have priority, as long as they are in LD_LIBRARY_PATH - otherwise they don't seem to be taken into consideration at all)