TeamFightingICE/FightingICE

Failed to dynamically load library libglfw.so(error = null)

Closed this issue · 1 comments

Hi dear developers,

I cannot start FTG4.5/ftg.sh in a Debian system. Could you help take a look?

I ran the following command

java -cp FightingICE.jar:./lib/lwjgl/*:./lib/natives/linux/*:./lib/* -Dorg.lwjgl.util.Debug=true Main --py4j --mute --port 4242

and saw the outputs:

[LWJGL] Version: 3.1.2 build 29
[LWJGL]          OS: Linux v4.19.117.bsk.5-amd64
[LWJGL]         JRE: 1.8.0_292 amd64
[LWJGL]         JVM: OpenJDK 64-Bit Server VM v25.292-b10 by AdoptOpenJDK
[LWJGL] Loading library (system): lwjgl
[LWJGL]         Found at: /tmp/lwjgl{USER_NAME}/3.1.2-build-29/liblwjgl.so
[LWJGL]         Loaded from org.lwjgl.librarypath: /tmp/lwjgl{USER_NAME}/3.1.2-build-29/liblwjgl.so
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Loading library: glfw
[LWJGL]         Found at: /tmp/lwjgl{USER_NAME}/3.1.2-build-29/libglfw.so
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to dynamically load library: /tmp/lwjgl{USER_NAME}/3.1.2-build-29/libglfw.so(error = null)
        at org.lwjgl.system.linux.LinuxLibrary.<init>(LinuxLibrary.java:22)
        at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:105)
        at org.lwjgl.system.Library.loadNative(Library.java:322)
        at org.lwjgl.system.Library.loadNative(Library.java:307)
        at org.lwjgl.system.Library.loadNative(Library.java:234)
        at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:602)
        at sun.misc.Unsafe.ensureClassInitialized(Native Method)
        at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
        at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:156)
        at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
        at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
        at java.lang.reflect.Field.getInt(Field.java:574)
        at org.lwjgl.system.APIUtil.apiClassTokens(APIUtil.java:259)
        at org.lwjgl.glfw.GLFWErrorCallback$1.<init>(GLFWErrorCallback.java:78)
        at org.lwjgl.glfw.GLFWErrorCallback.createPrint(GLFWErrorCallback.java:77)
        at manager.DisplayManager.initialize(DisplayManager.java:66)
        at manager.DisplayManager.start(DisplayManager.java:50)

But I was able to successfully start it on Mac or Ubuntu. No idea why it fails on this specific debian system.

Will appreciate if you could provide any help or clue.

Solved by installing missing dependencies.

For those who may encounter the same issue, first identify the dependencies by the command:

ldd /tmp/lwjgl{USER_NAME}/3.1.2-build-29/libglfw.so

then install the missing libs. In our case, it involves:

apt-get install -y \
        libxcursor1 \
        libxrandr2 \
        libxinerama-dev \
        ...

You may also need install xvfb for headless mode, as is described in this issue #6 .