加载 dll 库文件时出现问题... java.lang.UnsatisfiedLinkError: 无法加载库

发布于 2024-08-23 23:43:31 字数 895 浏览 6 评论 0原文

加载 dll 文件时,出现以下异常:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
  D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlp\bin\ia32-w32-msvc80\btrntjni.dll: 
  The system cannot find message text for message number 0x%1 in the message file for %2

at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.basistech.util.internal.Native.loadLibrary(Unknown Source)
at com.basistech.rnt.jni.<clinit>(Unknown Source)
at com.basistech.rnt.RNTEnvironment.<init>(Unknown Source)
at SampleTranslator.<init>(TranslateNameSample.java:88)
at TranslateNameSample.main(TranslateNameSample.java:62)

不确定问题的根本原因。谁能帮我解决这个问题。

谢谢, 巴斯卡

While loading a dll file, I am getting the following exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
  D:\Transliteration\rlpnc-3.1.0-sdk-ia32-w32-msvc80\rlp\bin\ia32-w32-msvc80\btrntjni.dll: 
  The system cannot find message text for message number 0x%1 in the message file for %2

at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.basistech.util.internal.Native.loadLibrary(Unknown Source)
at com.basistech.rnt.jni.<clinit>(Unknown Source)
at com.basistech.rnt.RNTEnvironment.<init>(Unknown Source)
at SampleTranslator.<init>(TranslateNameSample.java:88)
at TranslateNameSample.main(TranslateNameSample.java:62)

not sure about the root cause of the issue. Can anybody help me out in resolving this issue.

Thanks,
Bhaskar

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(6

七堇年 2024-08-30 23:43:31

我在生产您正在尝试使用的产品的公司工作。当它针对我们附带的底层的不兼容版本安装时,我们会看到此错误,因为正如其他人建议的那样,缺少依赖的 DLL。请随时联系我们的支持团队以获取更多帮助。

I work for the company that makes the product you're trying to use. We've seen this error when it's been installed against an incompatible version of the underlying layer we ship with it, because of missing dependent DLLs as others have suggested. Feel free to contact our support team for more help.

忆悲凉 2024-08-30 23:43:31

这与类路径无关。将 DLL 放置在当前目录、PATH 环境变量中列出的目录之一中,或者最重要的是,放置在本机库搜索路径中,使用系统属性 java.library.path 设置:

java -Djava.library.path=C:\MyNativeLibs MyMainClass

This does not have to do anything with the classpath. Place the DLL in the current directory, in one of the directories listed in the PATH environment variable, or, best of all, in the native library search path, set using the system property java.library.path:

java -Djava.library.path=C:\MyNativeLibs MyMainClass
百善笑为先 2024-08-30 23:43:31

除了检查您是否将 DLL 的路径放入正确的环境变量之外,您还应该检查以下内容:

  • 您正在加载的 DLL 是否满足其所有依赖项。换句话说,如果此 DLL 依赖于其他 DLL,请确保也可以找到这些 DLL。

  • 如果正在加载的 DLL 使用清单指定特定 DLL,请确保该 DLL(清单中指定的版本)也在计算机上(或在 GAC 中,如果需要)并且可以找到

  • 检查Java 代码中引用的所有 DLL 函数都已正确定义和导出,并且导出的数据类型与 Java 代码所期望的数据类型相同。这不会停止 DLL 加载,但很可能会扰乱下一阶段 - 解析链接地址或使应该工作的函数以意外的方式失败。

这样做会带来很多乐趣——很多小事情会让你绊倒。几年前,我不得不处理这个混乱的文本到语音包(在 DLL 中的 C 和 C++ 中),该包与具有新旧 JNI 样式的不同版本的 Java 一起使用。真是一团糟!

As well as checking your are putting the path to the DLL in the correct environment variable you should also check the following:

  • The DLL you are loading has all its dependencies satisfied. In other words, if this DLL depends on other DLLs, make sure those DLLs can also be found.

  • If the DLL being loaded uses a manifest to specify a specific DLL, ensure that DLL (of the version specified in the manifest) is also on the machine (or in the GAC, if required) and can be found

  • Check that all DLL functions referred in your Java code are correctly defined and exported and export the same datatypes as those your Java code is expecting. This won't stop the DLL loading, but it may well mess up the next stage - resolving link addresses or making functions that should work, fail in unexpected ways.

Lots of fun to be had with this - lots of little things to trip you up. I had to deal with this a few years back messing with a text to speech package (in C & C++ in a DLL) working with different versions of Java with old and new JNI styles. What a mess!

末蓝 2024-08-30 23:43:31

我自己没有看到这个问题,但从错误消息来看,DLL 所需的某些依赖项要么丢失,要么版本不正确。

此工具可能会有所帮助:http://www.dependencywalker.com/

I have not seen this problem myself, but from the error message it sounds like some dependency needed by the DLL is either missing or incorrect version.

This tool might help: http://www.dependencywalker.com/

药祭#氼 2024-08-30 23:43:31

对我来说,将 dll 路径添加到 IDE 中的 VM 选项是有效的。

For me, adding the dll path to the VM options in my IDE worked.

嘿哥们儿 2024-08-30 23:43:31

检查“java.library.path”是否包含包含.dll 文件的文件夹。
在 Windows 机器上它与 PATH 相关。
http://www.inonit.com/cygwin/jni/helloWorld/load。 html

Check that the "java.library.path" contains the folder containing .dll file.

On windows machine it is related to PATH.
http://www.inonit.com/cygwin/jni/helloWorld/load.html

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