Lwjgl3: Runtime library loading broken in LWJGL 3

Created on 26 Mar 2016  路  2Comments  路  Source: LWJGL/lwjgl3

I used this runtime library loader in LWJGL 2 to make it much easier to send a working JAR file to anyone, as it would load the libraries based on the operating system at runtime and I would not have to create multiple FAT JARs for each system. Now, I get this error whenever I try to use this implementation:

[LWJGL] Version: 3.0.0 build 26
[LWJGL] OS: Windows 10 v10.0
[LWJGL] JRE: 1.8.0_65 amd64
[LWJGL] JVM: Java HotSpot(TM) 64-Bit Server VM v25.65-b01 by Oracle Corporation
[LWJGL] Loaded library from java.library.path: lwjgl
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.lwjgl.system.MemoryManage.getInstance(MemoryManage.java:36)
at org.lwjgl.system.MemoryUtil.(MemoryUtil.java:66)
at org.lwjgl.system.libffi.Closure.(Closure.java:57)
at form2bgames.terminusengine.core.TerminusGame.start(TerminusGame.java:78)
at syl.tests.TestMain.main(TestMain.java:24)
Caused by: java.lang.RuntimeException: Failed to load library: jemalloc.dll (error code = 126)
at org.lwjgl.system.windows.WindowsUtil.windowsThrowException(WindowsUtil.java:28)
at org.lwjgl.system.windows.WindowsLibrary.(WindowsLibrary.java:33)
at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:81)
at org.lwjgl.system.Library.loadNative(Library.java:144)
at org.lwjgl.system.jemalloc.JEmalloc.(JEmalloc.java:89)
... 7 more
[LWJGL] [MemoryAllocator] Failed to load the jemalloc library.
[LWJGL] MemoryUtil allocator: StdlibAllocator
java.lang.ExceptionInInitializerError
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(Unknown Source)
at sun.reflect.ReflectionFactory.newFieldAccessor(Unknown Source)
at java.lang.reflect.Field.acquireFieldAccessor(Unknown Source)
at java.lang.reflect.Field.getFieldAccessor(Unknown Source)
at java.lang.reflect.Field.getInt(Unknown Source)
at org.lwjgl.system.APIUtil.apiClassTokens(APIUtil.java:191)
at org.lwjgl.glfw.GLFWErrorCallback$3.(GLFWErrorCallback.java:138)
at org.lwjgl.glfw.GLFWErrorCallback.createPrint(GLFWErrorCallback.java:137)
at form2bgames.terminusengine.core.TerminusGame.start(TerminusGame.java:78)
at syl.tests.TestMain.main(TestMain.java:24)
Caused by: java.lang.RuntimeException: Failed to load library: glfw.dll (error code = 126)
at org.lwjgl.system.windows.WindowsUtil.windowsThrowException(WindowsUtil.java:28)
at org.lwjgl.system.windows.WindowsLibrary.(WindowsLibrary.java:33)
at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:81)
at org.lwjgl.system.Library.loadNative(Library.java:144)
at org.lwjgl.glfw.GLFW.(GLFW.java:597)
... 11 more

The class that loads the libraries is at http://pastebin.com/WbPBZwFs , and the line of code (form2bgames.terminusengine.core.TerminusGame.start(TerminusGame.java:78)) is glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));. Setting the native path in eclipse to a folder with the natives for my system does let the program run.
Thanks for any responses.

Question

Most helpful comment

LWJGL 3 already supports automatically extracting native libraries from JARs. See the SharedLibraryLoader class for details. Have you tried using LWJGL without your custom loader?

All 2 comments

LWJGL 3 already supports automatically extracting native libraries from JARs. See the SharedLibraryLoader class for details. Have you tried using LWJGL without your custom loader?

@Spasi I'll look into that. And without the custom loader, the program will run if I set the natives path correctly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

voidburn picture voidburn  路  5Comments

thislooksfun picture thislooksfun  路  5Comments

knokko picture knokko  路  4Comments

ShadowLordAlpha picture ShadowLordAlpha  路  3Comments

Hugobros3 picture Hugobros3  路  7Comments