Could not initialize class org.lwjgl.system.MemoryAccess

Started by tomera, December 26, 2016, 23:48:05

Previous topic - Next topic

tomera

I try to use LWJGL3 with eclipse but I have runtime compile error related to the native. I downloaded the latest release (3.1.0 build 40) and included the native and the code jars in the build path as seen in the screen shot:



* yes I checked in order and export that they are marked.

However when running the code HelloWorld code I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.MemoryAccess
at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:76)
at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:563)
at gpu.HelloWorld.run(HelloWorld.java:29)
at gpu.HelloWorld.main(HelloWorld.java:100)


I have looked here, stackoverflow and google and could not find the answer.

- I tried to set the native put the native (the .so file outside the jar) and it not working.
- I tried using  -Djava.library.path and the path to the .so files and it not working

My linux OS is centos.

What am I doing wrong?


spasi

Try running with -Dorg.lwjgl.util.Debug=true and -Dorg.lwjgl.util.DebugLoader=true and inspect the output for an explanation of what might be wrong.

tomera

This is the error I get:

[LWJGL] Version: 3.1.0 build 40
[LWJGL] 	 OS: Linux v2.6.32-504.23.4.el6.centos.plus.x86_64
[LWJGL] 	JRE: 1.8.0_111 amd64
[LWJGL] 	JVM: Java HotSpot(TM) 64-Bit Server VM v25.111-b14 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] 	Found at: /tmp/lwjgltaviad/3.1.0-build-40/liblwjgl.so
[LWJGL] [TLS] Failed to initialize unsafe implementation.
[LWJGL] ThreadLocalUtil state: TLState
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.Library
	at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:56)
	at org.lwjgl.system.MemoryStack.<init>(MemoryStack.java:57)
	at org.lwjgl.system.MemoryStack.create(MemoryStack.java:76)
	at org.lwjgl.system.MemoryStack.create(MemoryStack.java:67)
	at org.lwjgl.system.ThreadLocalState.<init>(ThreadLocalState.java:24)
	at org.lwjgl.system.ThreadLocalUtil$TLState$1.initialValue(ThreadLocalUtil.java:61)
	at org.lwjgl.system.ThreadLocalUtil$TLState$1.initialValue(ThreadLocalUtil.java:58)
	at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
	at java.lang.ThreadLocal.get(ThreadLocal.java:170)
	at org.lwjgl.system.ThreadLocalUtil$TLState.get(ThreadLocalUtil.java:72)
	at org.lwjgl.system.ThreadLocalUtil.tlsGet(ThreadLocalUtil.java:30)
	at org.lwjgl.system.MemoryStack.stackPush(MemoryStack.java:589)
	at gpu.CLDemo.main(CLDemo.java:28)


spasi

Unfortunately there is an exception during class initialization and the stacktrace is not helpful. The message "Failed to initialize unsafe implementation" is also odd.

Does it work with a simpler demo? E.g. the getting started sample on the website.

Also, could you please try the same with an LWJGL 3.1.1 snapshot?

tomera

I can only test it next week.

It may be relate to the user permissions? I dont have root/sudo permissions on my user.

tomera

This the error I get when I run what you told me:

[LWJGL] Version: 3.1.2 build 1
[LWJGL] 	 OS: Linux v2.6.32-504.23.4.el6.centos.plus.x86_64
[LWJGL] 	JRE: 1.8.0_111 amd64
[LWJGL] 	JVM: Java HotSpot(TM) 64-Bit Server VM v25.111-b14 by Oracle Corporation
[LWJGL] Loading library (system): lwjgl
[LWJGL] 	Found at: /tmp/lwjgltaviad/3.1.2-build-1/liblwjgl.so
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.Library
	at org.lwjgl.system.MemoryAccessJNI.<clinit>(MemoryAccessJNI.java:13)
	at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
	at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:76)
	at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:566)
	at test2.HelloWorld.run(HelloWorld.java:29)
	at test2.HelloWorld.main(HelloWorld.java:105)

tomera

When running only this code:
public void run() {
		System.out.println("Hello LWJGL " + Version.getVersion() + "!");

			init();

	}


I get this error:


Hello LWJGL 3.1.2 build 1!
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/lwjgltaviad/3.1.2-build-1/liblwjgl.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /tmp/lwjgltaviad/3.1.2-build-1/liblwjgl.so)
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
	at java.lang.Runtime.load0(Runtime.java:809)
	at java.lang.System.load(System.java:1086)
	at org.lwjgl.system.Library.loadSystem(Library.java:138)
	at org.lwjgl.system.Library.loadSystem(Library.java:128)
	at org.lwjgl.system.Library.loadSystem(Library.java:96)
	at org.lwjgl.system.Library.<clinit>(Library.java:53)
	at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:56)
	at org.lwjgl.system.MemoryStack.<init>(MemoryStack.java:59)
	at org.lwjgl.system.MemoryStack.create(MemoryStack.java:78)
	at org.lwjgl.system.MemoryStack.create(MemoryStack.java:69)
	at java.lang.ThreadLocal$SuppliedThreadLocal.initialValue(ThreadLocal.java:284)
	at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
	at java.lang.ThreadLocal.get(ThreadLocal.java:170)
	at org.lwjgl.system.MemoryStack.stackGet(MemoryStack.java:594)
	at org.lwjgl.system.MemoryStack.stackPush(MemoryStack.java:603)
	at org.lwjgl.system.Callback.<clinit>(Callback.java:35)
	at test.HelloWorld.init(HelloWorld.java:27)
	at test.HelloWorld.run(HelloWorld.java:20)
	at test.HelloWorld.main(HelloWorld.java:95)





Kai

Because apparently it is the same cause: Requiring glibc 2.14, and you are running centos.

tomera


spasi

Hmm, is this a problem with how LWJGL is built? Any Linux expert around?

Kai

Looks like this is the way to go: http://stackoverflow.com/questions/4032373/linking-against-an-old-version-of-libc-to-provide-greater-application-coverage
Same: http://stackoverflow.com/questions/2856438/how-can-i-link-to-a-specific-glibc-version

$ objdump -p liblwjgl.so
...
Version References:
  required from libpthread.so.0:
    0x09691a75 0x00 03 GLIBC_2.2.5
  required from libc.so.6:
    0x09691974 0x00 06 GLIBC_2.3.4
    0x0d696917 0x00 05 GLIBC_2.7
    0x06969194 0x00 04 GLIBC_2.14
    0x09691a75 0x00 02 GLIBC_2.2.5

$ objdump -T liblwjgl.so | fgrep GLIBC_2.14
0000000000000000      DF *UND*	0000000000000000  GLIBC_2.14  memcpy

$ objdump -T /lib/x86_64-linux-gnu/libc.so.6 | grep -w memcpy
0000000000093840 g   iD  .text	000000000000006a  GLIBC_2.14  memcpy
000000000008e59b g   iD  .text	0000000000000057 (GLIBC_2.2.5) memcpy

sf17k

Same error on Ubuntu 16. I'm making a libgdx game built with gradle and sending it to testers on various systems. Just updated libgdx from 1.9.3 to 1.9.5, which also updated LWJGL from 3.0.0b to 3.1.0, and now my Ubuntu 16 tester can no longer run the game. It works fine on Mac and Windows, even Windows XP.

Can do more testing to confirm.

EDIT: Yep, downgrading libgdx back to 1.9.3 (and LWJGL to 3.0.0b) fixes the problem.

spasi

Could you please post the output with -Dorg.lwjgl.util.Debug=true and -Dorg.lwjgl.util.DebugLoader=true? I don't think it's the same error.

Could you also please post the output of ldd --version?