Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

huangapple go评论74阅读模式
英文:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

问题

你好,我正在尝试制作一个游戏引擎,目前在创建一个窗口时遇到了错误。

在你问之前,我已经包含了库slack-util和lwjgl。

错误信息:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void 
org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'
at org.lwjgl.opengl.WindowsDisplay.setWindowProc(Native Method)
at org.lwjgl.opengl.WindowsDisplay.<clinit>(WindowsDisplay.java:218)
at org.lwjgl.opengl.Display.createDisplayImplementation(Display.java:159)
at org.lwjgl.opengl.Display.<clinit>(Display.java:136)
at com.firenet.engine.Window.createWindow(Window.java:11)
at com.firenet.engine.MainComponent.main(MainComponent.java:11)

Window.java:

package com.firenet.engine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class Window 
{
    public static void createWindow(int width, int height, String title)
    {
        Display.setTitle("Test!");
        try 
        {
            Display.setDisplayMode(new DisplayMode(width, height));
            Display.create();
        } 
        catch (LWJGLException e) 
        {
            e.printStackTrace();
        }
    }
}

MainComponent.java:

package com.firenet.engine;

public class MainComponent 
{
    public static final int width = 600;
    public static final int height = 500;
    public static final String title = "Test!";
    
    public static void main(String[] args)
    {
        Window.createWindow(width, height, title);
    }
}
英文:

HelIo i am trying to make a game engine and right now to create a window with it but there is an error

I included the librarys slack-util and lwjgl before you ask me

The error:

Exception in thread &quot;main&quot; java.lang.UnsatisfiedLinkError: &#39;void 
org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)&#39;
at org.lwjgl.opengl.WindowsDisplay.setWindowProc(Native Method)
at org.lwjgl.opengl.WindowsDisplay.&lt;clinit&gt;(WindowsDisplay.java:218)
at org.lwjgl.opengl.Display.createDisplayImplementation(Display.java:159)
at org.lwjgl.opengl.Display.&lt;clinit&gt;(Display.java:136)
at com.firenet.engine.Window.createWindow(Window.java:11)
at com.firenet.engine.MainComponent.main(MainComponent.java:11)

Window.java:

package com.firenet.engine;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

public class Window 
{
    public static void createWindow(int width, int height, String title)
    {
	     Display.setTitle(&quot;Test!&quot;);
	     try 
	     {
		 Display.setDisplayMode(new DisplayMode(width, height));
	  	 Display.create();
	     } 
	     catch (LWJGLException e) 
	     {
		     e.printStackTrace();
	     }
      }
   }

MainComponent.java:

package com.firenet.engine;

public class MainComponent 
{
     public static final int width = 600;
     public static final int height = 500;
     public static final String title = &quot;Test!&quot;;

   	 public static void main(String[] args)
     {
	     Window.createWindow(width, height, title);
     }
}

答案1

得分: 2

你的问题似乎是你没有将“native”文件夹添加到构建路径中。我已经根据你在问题中提到的代码创建了一个项目。在正确添加了“natives”之后,我运行了你的代码,它显示了一个空白的黑色窗口,然后在一段时间后关闭。请尝试以下步骤:

  1. 在你的项目中(我在使用Eclipse),转到JRE系统库 > 构建路径 > 配置构建路径(通过右键单击JRE系统库)

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

  1. 接下来选择Java 构建路径 > 库(选项卡) > 本地库位置。然后点击“编辑”。

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

  1. 下一步是与操作系统相关的。在你下载的lwjgl中有一个名为“native”的目录。根据你使用的操作系统选择文件夹。例如,如果你使用的是Windows,则选择lwjgl-2.x.x > native > windows。我现在使用的是macOS,所以我会选择适用于mac的那个文件夹。

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

完成上述步骤后,运行你的应用程序,希望你能看到一个空白窗口,就像我在我的机器上运行时看到的一样。

英文:

Your problem seems to be that you have not added the "native" folder to your build path. I have created a project based on the code that you mentioned in the question. After adding the 'natives' correctly I ran your code, and it shows me a blank black window which closes after some time. Try the following:

  1. In your project (I am using Eclipse) go to JRE System Library > Build Path > Configure Build Path (by right clicking on JRE System Library)

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

  1. Next Select Java Build Path > Libraries (tab) > Native Library Location. Now press 'Edit'

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

  1. The next step is OS specific. In your download of lwjgl there is a directory 'native'. Select the folder based on the OS you are using. For example if you are using Windows then select lwjgl-2.x.x > native > windows. Now I am on a macOS so I will be using the one for mac.

Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.lwjgl.opengl.WindowsDisplay.setWindowProc(java.lang.reflect.Method)'

After this run your application and hopefully you will see a blank window like I see when I run it on my machine.

huangapple
  • 本文由 发表于 2020年10月3日 18:16:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/64183108.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定