Hello Guest

How do I setup the native libraries with maven?

  • 32 Replies
  • 15134 Views
*

Offline doev

  • *
  • 22
How do I setup the native libraries with maven?
« on: September 14, 2015, 08:38:44 »
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?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #1 on: September 14, 2015, 09:22:07 »
See this sample project, you must use:

Code: [Select]
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.
« Last Edit: September 21, 2015, 07:13:27 by spasi »

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #2 on: September 14, 2015, 09:36:55 »
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.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #3 on: September 14, 2015, 09:51:03 »
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.

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #4 on: September 14, 2015, 10:07:21 »
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.

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #5 on: September 14, 2015, 10:10:58 »
build #3.0.0b build 9 also works fine.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #6 on: September 14, 2015, 15:33:17 »
It sounds similar to this issue. edit: also this one.
« Last Edit: September 14, 2015, 18:47:14 by spasi »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #7 on: September 14, 2015, 19:09:22 »
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?

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #8 on: September 15, 2015, 08:44:55 »
Sorry, my fault. When I use 3.0.0b-SNAPSHOT I can't compile cause GLContext.createFromCurrent(); is not known.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #9 on: September 15, 2015, 08:47:41 »
See the latest getting started guide: you must use GL.createCapabilities().

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #10 on: September 15, 2015, 09:00:29 »
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();

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #11 on: September 15, 2015, 09:07:09 »
Does it help if you uninstall libgl1-mesa-dev? Also, what GPU do you have?

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #12 on: September 15, 2015, 09:16:55 »
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

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: How do I setup the native libraries with maven?
« Reply #13 on: September 15, 2015, 09:32:01 »
If it's not too much trouble, could you install libgl1-mesa-dev again, run this code and paste the output here?

Code: [Select]
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.

*

Offline doev

  • *
  • 22
Re: How do I setup the native libraries with maven?
« Reply #14 on: September 15, 2015, 09:50:23 »
Code: [Select]
contextGLFW  = 139802799196784
contextLWJGL = 139802799196784
displayGLFW  = 139802798297344
displayLWJGL = 0

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

There are two new links:
Code: [Select]
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
« Last Edit: September 15, 2015, 09:55:36 by doev »