-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
LibraryLoader.search() path not taken into consideration unless also in LD_LIBRARY_PATH #303
Comments
I'm fairly sure this is an issue because of I believe Solutions
Hope this helps |
Sorry for the confusion, but I used ~ as a placeholder for my home directory, in code and in commands I used absolute paths ( I guess the problem might be with some dlopen, or whatever underlying mechanism is being used that only looks in predefined library paths, and LD_LIBRARY_PATH? |
Alright, I've dug a little deeper, and I've discovered couple of things:
LibraryLoader.create(Lib.class).load("/home/ja/mylib/libmylib.so"); It's not possible to use full name of library, when not providing a path, because in such case LibraryLoader assumes that short name is being used (i.e.
For now I guess there are two workarounds that more or less work for me:
LibraryLoader.create(MyLib.class).failImmediately()
.load("/home/user/mylib/libmylib.so");
LibraryLoader.create(MyLib.class).failImmediately()
.option(LibraryOption.PreferCustomPaths, true)
.search("~/mylib")
.load("mylib"); |
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:
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
(byexport 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 fromLibraryLoader.search()
toLD_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 inLD_LIBRARY_PATH
- otherwise they don't seem to be taken into consideration at all)The text was updated successfully, but these errors were encountered: