12

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)

Update:

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.

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

liblwjgl.jnilib
openal.dylib

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

Appleshell
  • 7,088
  • 6
  • 47
  • 96
  • When I started libgdx, I made a mistake when I tried to run the "core" project instead of the desktop project, I think I had the same issue, and it usually works fine to use the gdx-setup-ui to start a new project. – Paul Jan 09 '14 at 23:10
  • 3
    I had the exact same issue and that little renaming trick you suggested did it for me. If you are someone who happened on this question, give this a spin just to make sure. – Aubergine Mar 27 '14 at 10:28
  • Thanks for the mention of renaming the .jnilib to .dylib. This worked for me! I'm using Hiero for SDF font rendering with https://www.npmjs.com/package/three-bmfont-text – Nick Desaulniers Sep 17 '15 at 18:26

2 Answers2

2

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:

  • Debug on Android / Robovm
  • Code on another machine until the problem is fixed

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

Stefan Carlson
  • 372
  • 3
  • 7
  • 21
0

Maybe you should try including the LWJGL .jar library into the source path, or the "core" directory.

Ferdz
  • 1,182
  • 1
  • 13
  • 31