libGDX 项目无法加载库 liblwjgl.dylib

2022-01-12 00:00:00 macos java libgdx

新的 libGDX 项目在运行桌面项目时无法加载库 liblwjgl.dylib.

A new libGDX project can't load the library liblwjgl.dylib when running the desktop project.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: 
/var/folders/4l/nsj9j4xj51g8h_6y_ndpnmc80000gn/T/libgdxChristian/3741154320/liblwjgl.dylib
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1798)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1080)
    at org.lwjgl.Sys$1.run(Sys.java:70)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
    at org.lwjgl.Sys.loadLibrary(Sys.java:95)
    at org.lwjgl.Sys.<clinit>(Sys.java:112)
    at org.lwjgl.openal.AL.<clinit>(AL.java:59)
    at com.badlogic.gdx.backends.openal.OpenALAudio.<init>(OpenALAudio.java:70)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:80)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:64)
    at com.foxhat.test.Main.main(Main.java:14)

更新:

我在 OSX 10.9 上运行 Java 1.8.同样的错误不仅出现在自己的项目中,而且出现在使用 libGDX 构建的外部 JAR 中.

I'm running Java 1.8 on OSX 10.9. The same error appears not only with an own project, but also with foreign JARs built with libGDX.

错误中提到的文件夹,其中 liblwjgl.dylib 被搜索,包含:

The folder mentioned in the error, where liblwjgl.dylib is searched, contains:

liblwjgl.jnilib
openal.dylib

liblwjgl.jnilib 重命名为 .dylib 确实适用于国外应用程序,但不适用于我自己的应用程序.

Renaming liblwjgl.jnilib to .dylib does work for the foreign application, but not for my own.

推荐答案

我认为这是 Java 7 和 LWJGL 之间的兼容性问题.出于某种原因,这也只会影响 OS X,因为它在我的 Windows 和 Ubuntu 机器上都可以正常工作,但在我的 Mac 上却不行.在问题得到解决之前,您可以使用的选项:

I believe this is a compatibility issue between Java 7 and LWJGL. For some reason, this also only affects OS X, as it works just fine on both my Windows and Ubuntu machines, but not my Mac. Your options to work with until the problem is fixed:

  • 在 Android/Robovm 上调试
  • 在另一台机器上编写代码,直到问题得到解决

考虑到您可以使用 Android 模拟器,我认为 Android 测试是最好的选择.

Considering you can use an Android emulator, I think Android testing is the best option.

相关文章