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.
at org.lwjgl.system.libffi.Closure.
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.
at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:81)
at org.lwjgl.system.Library.loadNative(Library.java:144)
at org.lwjgl.system.jemalloc.JEmalloc.
... 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.
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.
at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:81)
at org.lwjgl.system.Library.loadNative(Library.java:144)
at org.lwjgl.glfw.GLFW.
... 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.
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.
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?