[英]Getting 'java.lang.UnsatisfiedLinkError': no lwjgl in java.library.path
Note this is different from this question because it does not deal with linking because it's not asking how to link it via the CLI, but the GUI in Eclipse.请注意,这与此问题不同,因为它不涉及链接,因为它不询问如何通过 CLI 进行链接,而是询问 Eclipse 中的 GUI。
I have been trying to write a simple program using LWJGL.我一直在尝试使用 LWJGL 编写一个简单的程序。 When I add the library to Eclipse (Kepler 4.3.1 on Windows 7 64bit) and write a program, it does not show red squigglies under the the things which use LWJGL.
当我将库添加到 Eclipse(Windows 7 64 位上的开普勒 4.3.1)并编写程序时,它不会在使用 LWJGL 的东西下显示红色波浪线。 However, trying to run it gives me the following stacktrace:
但是,尝试运行它会给我以下堆栈跟踪:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.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 DisplayExample.start(DisplayExample.java:8)
at DisplayExample.main(DisplayExample.java:23)
(Yes, that is the example they give first, but I wanted to run it to make sure everything was installled properly) (是的,这是他们首先给出的例子,但我想运行它以确保一切都正确安装)
My question is, how do I fix this error?我的问题是,如何修复此错误? Note that, even when running in Eclipse, it still fails.
请注意,即使在 Eclipse 中运行,它仍然会失败。 If I run something else which does not use LWJGL it works, too.
如果我运行其他不使用 LWJGL 的东西,它也可以工作。 I just downloaded it from the inte.net - it only had one version, so I assume it was the correct one.
我刚从 inte.net 下载它 - 它只有一个版本,所以我认为它是正确的。 From what I can see, none of the other question askers have the same error as me - but if you could point me to informative questions that would be helpful too.
据我所知,其他提问者都没有和我一样的错误 - 但如果你能指出我的信息性问题也会有所帮助。
You don't have the natives set up in your LWJGL application.您没有在 LWJGL 应用程序中设置本机。
Here's how to do it:这是如何做到的:
Hope this helped :)希望这有帮助:)
I was following the tutorial here , and it looks like I didn't do the Adding the natives step, or I did it incorrectly.我正在关注这里的教程,看起来我没有执行添加本地人步骤,或者我做错了。
Follow the instructions in that link and the problem should be resolved:按照该链接中的说明操作,问题应该得到解决:
This is done by clicking the little arrow next to the lwjgl.jar file to show the drop down list.
这是通过单击 lwjgl.jar 文件旁边的小箭头显示下拉列表来完成的。 Double click 'Native library location' and select the folder that contains the native files for your operating system and clicking OK.
双击“本机库位置”并选择包含操作系统本机文件的文件夹,然后单击“确定”。 These are located in the natives folder include in the LWJGL download bundle (eg On Windows you'd point to the natives\\windows folder which contains the *.dll files, On Mac you'd point to the natives/macosx folder and on Linux you'd point to the natives/linux folder).
这些位于 LWJGL 下载包中的 natives 文件夹中(例如,在 Windows 上,您将指向包含 *.dll 文件的 natives\\windows 文件夹,在 Mac 上,您将指向 natives/macosx 文件夹,在 Linux 上你会指向 natives/linux 文件夹)。
If you try tu run this code:如果您尝试运行此代码:
public static void main(String... args){
System.out.println(System.getProperty("java.library.path"));
}
you should get output like this: /Users/yourName/.sdkman/candidates/java/8.0.252.j9-adpt/jre/lib/compressedrefs:/Users/yourName/.sdkman/candidates/java/8.0.252.j9-adpt/jre/lib:/usr/lib你应该得到这样的输出:/Users/yourName/.sdkman/candidates/java/8.0.252.j9-adpt/jre/lib/compressedrefs:/Users/yourName/.sdkman/candidates/java/8.0.252.j9 -adpt/jre/lib:/usr/lib
So, you just need to download LWJGL libraries and copy files located at "...native/yourOSname" to one of this folders因此,您只需下载 LWJGL 库并将位于“...native/yourOSname”的文件复制到此文件夹之一
That works to me fine!这对我很好!
I solved the issue by adding the lwjgl.64.dll file to the jdk-14.0.1 bin folder我通过将 lwjgl.64.dll 文件添加到 jdk-14.0.1 bin 文件夹中解决了这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.