英文:
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 "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);
}
}
答案1
得分: 2
你的问题似乎是你没有将“native”文件夹添加到构建路径中。我已经根据你在问题中提到的代码创建了一个项目。在正确添加了“natives”之后,我运行了你的代码,它显示了一个空白的黑色窗口,然后在一段时间后关闭。请尝试以下步骤:
- 在你的项目中(我在使用Eclipse),转到JRE系统库 > 构建路径 > 配置构建路径(通过右键单击JRE系统库)
- 接下来选择Java 构建路径 > 库(选项卡) > 本地库位置。然后点击“编辑”。
- 下一步是与操作系统相关的。在你下载的lwjgl中有一个名为“native”的目录。根据你使用的操作系统选择文件夹。例如,如果你使用的是Windows,则选择lwjgl-2.x.x > native > windows。我现在使用的是macOS,所以我会选择适用于mac的那个文件夹。
完成上述步骤后,运行你的应用程序,希望你能看到一个空白窗口,就像我在我的机器上运行时看到的一样。
英文:
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:
- In your project (I am using Eclipse) go to JRE System Library > Build Path > Configure Build Path (by right clicking on JRE System Library)
- Next Select Java Build Path > Libraries (tab) > Native Library Location. Now press 'Edit'
- 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.
After this run your application and hopefully you will see a blank window like I see when I run it on my machine.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论