2017-07-25 62 views
0

我開始學習如何使用LWJGL。我查看了Youtube並複製了幾行代碼。當我編譯它,它的工作,但是當我試圖運行它,它說:如何修復Eclipse在Eclipse上無法加載錯誤?

[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: liblwjgl32.so 
    at org.lwjgl.system.Library.loadSystem(Library.java:146) 
    at org.lwjgl.system.Library.loadSystem(Library.java:66) 
    at org.lwjgl.system.Library.<clinit>(Library.java:49) 
    at org.lwjgl.system.MemoryAccessJNI.<clinit>(MemoryAccessJNI.java:13) 
    at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22) 
    at org.lwjgl.system.Platform.mapLibraryNameBundled(Platform.java:80) 
    at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:602) 
    at Main.main(Main.java:6) 

這是我從Youtube複製代碼:

import static org.lwjgl.glfw.GLFW.*; 
import org.lwjgl.glfw.GLFWVidMode; 

public class Main { 
    public static void main (String[] args) { 
     if (!glfwInit()) { 
      throw new IllegalStateException("Failed to initialize GLFW!"); 
     } 
     glfwWindowHint(GLFW_VISIBLE,GLFW_FALSE); 
     long window = glfwCreateWindow(640, 480, "My Program", 0, 0); 
     if (window == 0) { 
      throw new IllegalStateException("Failed to create window!"); 
     } 
     GLFWVidMode videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor()); 
     glfwSetWindowPos(window, (videoMode.width() - 640)/2, (videoMode.height() - 480)/2); 
     glfwShowWindow(window); 
     while (!glfwWindowShouldClose(window)) { 
      glfwPollEvents(); 
     } 
    } 
} 

回答

0

這是一個錯誤,因爲你沒有按」在你的類路徑中擁有所有的依賴關係。您需要添加LWJGL jar及其所有依賴項。

克服此錯誤後再試(UnsatisfiedLinkError)。

相關問題