JOGL Exception- Can't find gluegen- rt in java

2019-04-08 22:21发布

问题:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860) at java.lang.Runtime.loadLibrary0(Runtime.java:845) at java.lang.System.loadLibrary(System.java:1084) at com.jogamp.gluegen.runtime.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:102) at com.jogamp.gluegen.runtime.NativeLibLoader.access$000(NativeLibLoader.java:51) at com.jogamp.gluegen.runtime.NativeLibLoader$1.run(NativeLibLoader.java:70) at java.security.AccessController.doPrivileged(Native Method) at com.jogamp.gluegen.runtime.NativeLibLoader.loadGlueGenRT(NativeLibLoader.java:68) at com.jogamp.common.jvm.JVMUtil.(JVMUtil.java:56) at javax.media.opengl.GLProfile.(GLProfile.java:1051) at HelloWorld.main(HelloWorld.java:14)

So i get this lovely exception everytime I try to run a tutorial JOGL file. I have desperately tried everything I could. Adding all possible libraries for jogl and gluegen including:

jogl.jar jogl.all.jar jogl natives gluegen natives gluegen and jogle natives for macosx

Everything, and it says that there is no gluegen library though there obviously is. -.- I read somewhere about jnilib files and tried putting them into the folders with the jar files, but still no luck.

I am using Eclipse, by the way.

回答1:

The OS has to be told where to find the gluegen-rt native library when it tries to run the application, which you can do by editing the "run configuration" in Eclipse to set the appropriate environment variable. I develop on Linux, and for me the steps are

  • right-click on the main class in the project explorer
  • select Run As -> Run Configurations...
  • select the Environment tab
  • click "New..."
  • enter Name: LD_LIBRARY_PATH and Value: /usr/lib64/jogl:/usr/lib64/gluegen
  • click "OK", "Apply", "Run"

On Mac OSX you will probably have to use DYLD_FALLBACK_LIBRARY_PATH or DYLD_LIBRARY_PATH instead of LD_LIBRARY_PATH, and the location of the JOGL and Gluegen libraries will be different. These are the directories containing the native libraries, with names ending in .so on Linux and I believe .jnilib on Mac OSX.