Search code examples
javalwjglunsatisfiedlinkerror

LWJGL 'java.lang.UnsatisfiedLinkError': no lwjgl in java.library.path


Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.libr
ary.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at org.lwjgl.Sys$1.run(Sys.java:73)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
        at org.lwjgl.Sys.loadLibrary(Sys.java:95)
        at org.lwjgl.Sys.<clinit>(Sys.java:112)
        at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
        at org.lorana.client.Lorana.<init>(Lorana.java:20)
        at org.lorana.client.Lorana.main(Lorana.java:31)

The error still persists after I've linked all native libraries to every referenced library, and followed the instructions of http://ninjacave.com/lwjglwitheclipse

I've also followed other questions on the board regarding lwjgl unsatisfiedlinkerrors, but to no avail.

Would very much appreciate the help, Thanks in advance!


Solution

  • LWJGL uses its own variables for the path to the native libraries:

     System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());
    


    If you kept the file structure from the LWJGL package you can use something like this:

        switch(LWJGLUtil.getPlatform())
        {
            case LWJGLUtil.PLATFORM_WINDOWS:
            {
                JGLLib = new File("./native/windows/");
            }
            break;
    
            case LWJGLUtil.PLATFORM_LINUX:
            {
                JGLLib = new File("./native/linux/");
            }
            break;
    
            case LWJGLUtil.PLATFORM_MACOSX:
            {
                JGLLib = new File("./native/macosx/");
            }
            break;
        }
    
        System.setProperty("org.lwjgl.librarypath", JGLLib.getAbsolutePath());