什么是 LD_LIBRARY_PATH 以及如何使用它?

发布于 2024-12-01 01:53:31 字数 289 浏览 4 评论 0原文

我参与开发一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

椒妓 2024-12-08 01:53:31

LD_LIBRARY_PATH 是 Linux/Unix 中预定义的环境变量,它设置链接器在链接动态库/共享库时应查找的路径。

LD_LIBRARY_PATH 包含以冒号分隔的路径列表,链接器优先考虑这些路径,而不是标准库路径 /lib/usr/lib。仍会搜索标准路径,但前提是 LD_LIBRARY_PATH 中的路径列表已用尽。

使用 LD_LIBRARY_PATH 的最佳方法是在执行程序之前立即在命令行或脚本中设置它。这样,新的LD_LIBRARY_PATH就与系统的其余部分隔离了。

用法示例:

$ export LD_LIBRARY_PATH="/list/of/library/paths:/another/path"
$ ./program

由于您谈论的是 .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 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.

遗心遗梦遗幸福 2024-12-08 01:53:31

通常,您必须在 JVM 命令行上设置 java.library.path:

java -Djava.library.path=/path/to/my/dll -cp /my/classpath/goes/here MainClass

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
冰之心 2024-12-08 01:53:31

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).

小霸王臭丫头 2024-12-08 01:53:31

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.

风启觞 2024-12-08 01:53:31

我的错误还与服务找不到所需的 .so 文件有关。
我使用 LD_LIBRARY_PATH 变量来优先考虑链接器选择的路径来搜索所需的库。

我将服务和 .so 文件复制到一个文件夹中,并将其提供给 LD_LIBRARY_PATH 变量,就像

LD_LIBRARY_PATH=. ./service

在我给出上述命令的同一文件夹中一样,它起作用了。

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 to LD_LIBRARY_PATH variable as

LD_LIBRARY_PATH=. ./service

being in the same folder I have given the above command and it worked.

迟月 2024-12-08 01:53:31

好吧,错误消息告诉你该怎么做:将 Jacob.dll 所在的路径添加到 java.library.path 中。您可以在命令行上执行此操作,如下所示:(

java -Djava.library.path="dlls" ...

假设 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:

java -Djava.library.path="dlls" ...

(assuming Jacob.dll is in the "dlls" folder)

Also see java.lang.UnsatisfiedLinkError no *****.dll in java.library.path

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文