How do I setup the native libraries with maven?

Started by doev, September 14, 2015, 08:38:44

Previous topic - Next topic

doev

Hello,

if I use lwjgl3 in the manual way I have to set "-Djava.library.path=<dir>/lwjgl_3.0.0a/native" to run the application. How is the recommend way to set this with maven?

spasi

See this sample project, you must use:

SharedLibraryLoader.load();


Please note that, before the official release of LWJGL 3.0, a similar solution will be included in LWJGL.

edit: The above is not required with the latest nightly builds.

doev

Thx. The project takes me one step forward. Now I get "Invalid X server connection specified" and I remember this problem appears if you are working with glfw in the wrong thread. But the demoproject (your link) is not working with threads.

spasi

Try the latest nightly build. Use this maven URL: https://oss.sonatype.org/content/repositories/snapshots/ and this LWJGL version: 3.0.0b-SNAPSHOT.

If that doesn't work, make sure OpenGL is working fine on your machine.

doev

3.0.0b-SNAPSHOT does not change the problem, same error. But I tested Lwjgl3Test.java with "LWJGL 3.0.0a build 48 (ZIP)" and it works well.

doev


spasi


spasi

Actually, the latest 3.0.0b-SNAPSHOT doesn't have an "Invalid X server connection specified" error. Are you sure you tested the correct build?

doev

Sorry, my fault. When I use 3.0.0b-SNAPSHOT I can't compile cause GLContext.createFromCurrent(); is not known.

spasi

See the latest getting started guide: you must use GL.createCapabilities().

doev

I changed "GLContext.createFromCurrent()" to "GL.createCapabilities()" and also test the HelloWorld.java example with an additional "SharedLibraryLoader.load()". In both cases I get a NullPointer-Exception:

Exception in thread "main" java.lang.NullPointerException
   at org.lwjgl.system.Checks.checkPointer(Checks.java:80)
   at org.lwjgl.opengl.GL.createCapabilities(GL.java:278)
   at org.lwjgl.opengl.GL.createCapabilities(GL.java:230)
   at HelloWorld.loop(HelloWorld.java:93)
   at HelloWorld.run(HelloWorld.java:26)
   at HelloWorld.main(HelloWorld.java:114)

Edit:

Line 93: GL.createCapabilities();

spasi

Does it help if you uninstall libgl1-mesa-dev? Also, what GPU do you have?

doev

Removing libgl1-mesa-dev which includes libqt4-opengl-dev and libglu1-mesa-dev helps. Now the examples are working.

GeForce GTS 450
346.82
Linux-x86_64

spasi

If it's not too much trouble, could you install libgl1-mesa-dev again, run this code and paste the output here?

System.out.println("contextGLFW  = " + GLFWLinux.glfwGetGLXContext(window));
System.out.println("contextLWJGL = " + GLX.glXGetCurrentContext());

long glXGetCurrentDisplay = GL.getFunctionProvider().getFunctionAddress("glXGetCurrentDisplay");
if ( glXGetCurrentDisplay != NULL ) {
	long displayGLFW = GLFWLinux.glfwGetX11Display();
	long displayLWJGL = JNI.callP(glXGetCurrentDisplay);

	System.out.println("displayGLFW  = " + displayGLFW);
	System.out.println("displayLWJGL = " + displayLWJGL);
} else {
	System.out.println("glXGetCurrentDisplay not found.");
}


Add it between glfwMakeContextCurrent(window) and GL.createCapabilities(). There is a good chance that simply reinstalling libgl1-mesa-dev won't reproduce the issue. If that happens, try reinstalling the Nvidia drivers, after libgl1-mesa-dev.

edit: Also, see if mesa adds a "libGL.so.1" symlink anywhere.

doev

contextGLFW  = 139802799196784
contextLWJGL = 139802799196784
displayGLFW  = 139802798297344
displayLWJGL = 0


I don't see any new symlink to libGL.so.1

There are two new links:
lrwxrwxrwx 1 root root 13 Mär 11  2015 /usr/lib/x86_64-linux-gnu/libGL.so -> mesa/libGL.so
lrwxrwxrwx 1 root root 14 Mär 11  2015 /usr/lib/x86_64-linux-gnu/mesa/libGL.so -> libGL.so.1.2.0