What is LD_LIBRARY_PATH and how to use it?
I take part in developing a Java project, which uses some C++ components, thus I need Jacob.dll
. (on Windows 7)
I keep getting java.lang.UnsatisfiedLinkError: no JacobDB in java.library.path
no matter where I put Jacob.dll....
I looked for possible decisions and the one that I haven't tried so far is setting the LD_LIBRARY_PATH
variable, pointing at the .dll file.
I have little experience and I'm not familiar with what should be the meaning and usage of that variable - can you help me?
Solution 1:
LD_LIBRARY_PATH
is the predefined environmental variable in Linux/Unix which sets the path which the linker should look in to while linking dynamic libraries/shared libraries.
LD_LIBRARY_PATH
contains a colon separated list of paths and the linker gives priority to these paths over the standard library paths /lib
and /usr/lib
. The standard paths will still be searched, but only after the list of paths in LD_LIBRARY_PATH
has been exhausted.
The best way to use LD_LIBRARY_PATH
is to set it on the command line or script immediately before executing the program. This way the new LD_LIBRARY_PATH
isolated from the rest of your system.
Example Usage:
$ export LD_LIBRARY_PATH="/list/of/library/paths:/another/path"
$ ./program
Since you talk about .dll
you are on a windows system and a .dll
must be placed at a path which the linker searches at link time, in windows this path is set by the environmental variable PATH
, So add that .dll
to PATH
and it should work fine.
Solution 2:
Typically you must set java.library.path
on the JVM's command line:
java -Djava.library.path=/path/to/my/dll -cp /my/classpath/goes/here MainClass
Solution 3:
LD_LIBRARY_PATH
is Linux specific and is an environment variable pointing to directories where the dynamic loader should look for shared libraries.
Try to add the directory where your .dll is in the PATH variable. Windows will automatically look in the directories listed in this environment variable. LD_LIBRARY_PATH
probably won't solve the problem (unless the JVM uses it - I do not know about that).
Solution 4:
LD_LIBRARY_PATH
is the default library path which is accessed to check for available dynamic and shared libraries. It is specific to linux distributions.
It is similar to environment variable PATH
in windows that linker checks for possible implementations during linking time.