什么是 LD_LIBRARY_PATH 以及如何使用它?
我参与开发一个Java项目,该项目使用了一些C++组件,因此我需要Jacob.dll
。 (在 Windows 7 上)
无论我将 Jacob.dll 放在哪里,我都会不断收到 java.lang.UnsatisfiedLinkError: no JacobDB in java.library.path
...到目前为止,我还没有尝试过设置 LD_LIBRARY_PATH 变量,使其指向 .dll 文件。
我的经验很少,我不熟悉该变量的含义和用法 - 你能帮助我吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
LD_LIBRARY_PATH
是 Linux/Unix 中预定义的环境变量,它设置链接器在链接动态库/共享库时应查找的路径。LD_LIBRARY_PATH
包含以冒号分隔的路径列表,链接器优先考虑这些路径,而不是标准库路径/lib
和/usr/lib
。仍会搜索标准路径,但前提是LD_LIBRARY_PATH
中的路径列表已用尽。使用 LD_LIBRARY_PATH 的最佳方法是在执行程序之前立即在命令行或脚本中设置它。这样,新的
LD_LIBRARY_PATH
就与系统的其余部分隔离了。用法示例:
由于您谈论的是
.dll
,因此您位于 Windows 系统上,并且.dll
必须放置在链接器在链接时搜索的路径中,在 Windows 中,此路径是由环境变量PATH
设置的,因此将.dll
添加到PATH
,它应该可以正常工作。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 inLD_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 newLD_LIBRARY_PATH
isolated from the rest of your system.Example Usage:
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 variablePATH
, So add that.dll
toPATH
and it should work fine.通常,您必须在 JVM 命令行上设置 java.library.path:
Typically you must set
java.library.path
on the JVM's command line:LD_LIBRARY_PATH 是 Linux 特定的,是一个环境变量,指向动态加载器应在其中查找共享库的目录。
尝试将 .dll 所在的目录添加到 PATH 变量中。 Windows 将自动查找此环境变量中列出的目录。
LD_LIBRARY_PATH
可能无法解决问题(除非 JVM 使用它 - 我不知道)。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).LD_LIBRARY_PATH
是默认库路径,访问该路径以检查可用的动态库和共享库。它特定于 Linux 发行版。它类似于 Windows 中的环境变量 PATH,链接器在链接期间检查可能的实现。
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.我的错误还与服务找不到所需的
.so
文件有关。我使用 LD_LIBRARY_PATH 变量来优先考虑链接器选择的路径来搜索所需的库。
我将服务和 .so 文件复制到一个文件夹中,并将其提供给 LD_LIBRARY_PATH 变量,就像
在我给出上述命令的同一文件夹中一样,它起作用了。
My error was also related to not finding the required
.so
file by a service.I used
LD_LIBRARY_PATH
variable to priorities the path picked up by the linker to search the required lib.I copied both service and
.so
file in a folder and fed it toLD_LIBRARY_PATH
variable asbeing in the same folder I have given the above command and it worked.
好吧,错误消息告诉你该怎么做:将 Jacob.dll 所在的路径添加到 java.library.path 中。您可以在命令行上执行此操作,如下所示:(
假设 Jacob.dll 位于“dlls”文件夹中)
另请参阅 java.lang.UnsatisfiedLinkError java.library.path 中没有 *****.dll
Well, the error message tells you what to do: add the path where Jacob.dll resides to java.library.path. You can do that on the command line like this:
(assuming Jacob.dll is in the "dlls" folder)
Also see java.lang.UnsatisfiedLinkError no *****.dll in java.library.path