【问题标题】:Can't load native library on other systems无法在其他系统上加载本机库
【发布时间】:2014-11-27 11:37:36
【问题描述】:

我正在开发一个使用libjahspotify 的应用程序。该程序正在我的桌面 (Windows 7) 上运行,当尝试在我的笔记本电脑 (Windows 8.1) 或我的其他英特尔 NUC (Windows 7) 上运行它时,我收到以下错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\temp\jahspotify.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1083)
    at jahspotify.JahSpotifyNativeLoader.<init>(JahSpotifyNativeLoader.java:90)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
    at java.lang.Class.newInstance(Class.java:438)
    at jahspotify.impl.JahSpotifyImpl.<clinit>(JahSpotifyImpl.java:730)
    at jahspotify.services.JahSpotifyService.initialize(JahSpotifyService.java:56)
    at jahspotify.services.JahSpotifyService.getInstance(JahSpotifyService.java:26)
    at jahspotify.services.JahSpotifyService.initialize(JahSpotifyService.java:39)
    at net.functionseven.divicantus.spotify.Spotify.init(Spotify.java:29)
    at net.functionseven.divicantus.Divicantus.main(Divicantus.java:20)

libjahspotify 中的 native-jar 应该会自动加载 dll,但不会。此时似乎没有加载 jahspotify.dll。如果我手动将 jahspotify.dll 复制到文件夹中,native-jar 将按照预期删除它。

我已经多次重新编译 libjahspotify 并多次检查 java 和 dll 都是 x86。我也尝试使用 System.load() 手动加载它,我收到类似下面的错误。

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: C:\temp\jahspotify.dll
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1083)
    at net.functionseven.divicantus.Divicantus.main(Divicantus.java:24)

我不知道发生了什么。

【问题讨论】:

  • 欢迎使用 StackOverflow。请提供一些代码(最好是 SSCCE)。

标签: java dll java-native-interface spotify


【解决方案1】:

最可能的原因是第二个系统缺少一些 jahspotify.dll 需要的 dll。您可以使用 Dependency Walker (http://www.dependencywalker.com/) 检查需要哪些 dll,并尝试手动将它们放在 jahspotify.dll 旁边。通常缺少的 DLL 来自 c++ 可再发行包等。

【讨论】:

  • 就是这样。安装了 VS c++ 重新分发。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-05
  • 2014-05-06
  • 1970-01-01
  • 2019-04-12
  • 1970-01-01
  • 2013-01-24
  • 1970-01-01
相关资源
最近更新 更多