Windows DLL not found in lwjgl jar file
Answered
I try to run the LWJGL libraries aquired from lwjgl.org. I have loaded all jar files into my project as instructed on https://github.com/LWJGL/lwjgl3-wiki/wiki/1.2.-Install but when running the program it throws a library not found error. It can't open the lwjgl.dll in onw of the jars. That problem is by far not new. I found similar postings going back to 2011 (example: http://forum.lwjgl.org/index.php?topic=6938.0). The solution suggestion is always to make sure that the jars appear in the Class Path. This is the case in my project but still it doesn't work. The solution is probably simple but I fail to see it.
Do I have to first 'unpack' the jar file somehow for the native jars?
Can anybody help me?
Please sign in to leave a comment.
Hi. It is hard to advise without the project source. Does it work when you build a project with a build tool, for example, Maven?
Hi Petr. I have just uploaded a copy of the project on https://intellij-support.jetbrains.com/hc/en-us/articles/206869619-Uploading-Large-Files-for-JetBrains-Support-Team. The zip file name is "LWGL-Test 2020-06-19_04-00-01.zip". I tried various ways to get those libraries installed, including Maven. When I use Maven it shows the libraries - to my understanding - correctly in the pom.xml, in Project Structure/Project Settings/Libraries and Project Struture/Project Settings / Modules / Dependencies. The Natives are showing too. I guess it has something to do with the class path - just as several postings I found in the Internet seem t suggest - only I can't resolve it.
The output is:
Hello LWJGL 3.2.3 build 13!
[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.system.MemoryUtil.<clinit>(MemoryUtil.java:97)
at org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
at org.lwjgl.system.Callback.<clinit>(Callback.java:41)
at Test01.init(Test01.java:33)
at Test01.run(Test01.java:18)
at Test01.main(Test01.java:113)
Hi, Roland. Sorry for the delay, Could you please clarify, what kind of Run/Debug configuration do you use to build a project? The project compiles fine if I use the "Compile" maven goal from IDEA.
Hi Petr
I have taken a couple of snapshots from various settings. I am not sure whether this is what you are looking for ('Run/Debug configuration"). Let me know if you need me to look somwhere else.
I have sent the info to 'intellij-support@jetbrains.com' and asked them to forward it to you.
Please note that the build process works OK. The issue appears when running it.
Regards Roland
Hi, Roland.
Could you please describe, how exactly are you building the project? Regarding Run/Debug, please check https://www.jetbrains.com/help/idea/run-debug-configuration.html
Hi, Petr. I saved the run/debug configuration in an XML file following the instructions in https://www.jetbrains.com/help/idea/run-debug-configuration.html.
There is not much in it. So, I am not sure if that is of any additional help here. The project compiles without problem. The error occurs when running it.
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test01" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Test01" />
<module name="GeneralTestbed" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
Where do you have lwjgl.dll file located?
It must be either in PATH or you need to specify -Djava.library.path=/some/directory where this file is located in the VM options field of the Run/Debug configuration.
If the issue persists, please zip and share the project directory at https://uploads.jetbrains.com .
Hi Serge. I have upladed a zip file:
Upload ID: 2020_08_29_Kf7grLw1CTFQnXpV (file: LWGL Problem .zip).
It contains a pdf with various listings and screenshots and a zip of the complete project directory. As said above, the project build works OK. When running it, the error message comes immediately.
The (Windows) Path is:
C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Lenovo\FusionEngine;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Skype\Phone\;C:\windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\dotnet\;C:\Program Files (x86)\7-Zip;
I am not familiar with the class path that is managed in the IDE. I guess that is probably the key to the problem resolution.
Can't reproduce the issue:
LWGL should unpack and configure the native libraries automatically from the temp directory, if I check the process of the app, the DLL is loaded from my temp folder:
It's not clear why it doesn't work on your system. It could be some issue with the temp folder location or an antivirus blocking the libraries loading from the temp directory.
Check the error instructions you see in the console and try adding -Dorg.lwjgl.util.Debug=true in the IDE VM Options to get more verbose output which may help to understand why it doesn't work for you:
If I run with this option, here is the output showing where DLL is loaded from:
Hi Serge. Finally! Two things had to happen to make it work:
- I had to fetch the actual DLLs from https://www.lwjgl.org/browse/stable/windows/x86.(instead of using the JARs)
- Following your suggestion I added the option ' -Dorg.lwjgl.util.Debug=true' to the VM options to get more info.
The extended error message told me that I should extend the class path. On https://stackoverflow.com/questions/854264/how-to-add-directory-to-classpath-in-an-application-run-profile-in-intellij-idea I found a hint that it can be done with another VM options setting: -cp $Classpath$;"C:\Program Files\lwgl".
The required dlls I identified with trial-and-error (actually for this small demo program only 3 are required).
Now I know one way to handle this. I just wonder, if that should not be easier when working with Maven. Initially I got the impression, that by using Maven that would be sorted out for me.
I consider this issues as solved. Thanks for your patience with me.
And I realize now that you said so in a previous advise given above.