Help! Can't load a library.

Started by Tim Stark, May 12, 2021, 20:10:49

Previous topic - Next topic

Tim Stark

Folks,

I am new to LWJGL API programming.  I learned how to set LWJGL library for my Java programs.  I was able compile them into executable and run it.

I deleted LWJGL3 from user libraries and put them back in many different ways but always got the same message below.
I tried to set native directory to native libraries but still get the same error messages.

My eclipse version is 2021-03 and Java compiler version is Adopt OpenJDK 11 and 16.

Thanks,
Tim

I got loading library error messages.

[LWJGL] Failed to load a library. Possible solutions:
   a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
   b) Add the JAR that contains the shared library to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: lwjgl.dll
   at org.lwjgl.system.Library.loadSystem(Library.java:162)
   at org.lwjgl.system.Library.loadSystem(Library.java:62)
   at org.lwjgl.system.Library.<clinit>(Library.java:50)
   at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:674)
   at ofs.Main.init(Main.java:18)
   at ofs.Main.main(Main.java:39)

My simple Java program:

package ofs;

import static org.lwjgl.glfw.GLFW.glfwInit;
import static org.lwjgl.glfw.GLFW.glfwSetErrorCallback;
import static org.lwjgl.glfw.GLFW.glfwTerminate;
import static org.lwjgl.glfw.GLFWVulkan.glfwVulkanSupported;

import java.util.Objects;

import org.lwjgl.glfw.GLFWErrorCallback;

public class Main {

   private static void init()
   {
//      GLFWErrorCallback.createPrint().set();
      
      if (!glfwInit())
         throw new IllegalStateException("Unable initialize GLFW - aborted.");
      
      if (!glfwVulkanSupported())
         throw new IllegalStateException("GLFW do not support Vulkan interface - aborted.");
   }
   
   private static void cleanup()
   {
      glfwTerminate();
//      Objects.requireNonNull(glfwSetErrorCallback(null).set()).free();
   }
   
   public static void main(String[] args) {
      System.out.print("Wlecome to Orbital Flight Similator\n");
      
      init();
      cleanup();
   }

}

Tim Stark

I spent a lot of times to search for solutions.  I analyzed each jar files and noticed something was missing about lwjgl.dll.  It was not in all JAR files.   I checked other complete downloads and added lwjgl-natives-windows.jar to LWJGL3 user library.  All problems disappeared!