lwjglgamedev / vulkanbook

Online book which introduces the main concepts required to write graphics games or any other applications using Vulkan in Java by using the LWJGL library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error on MacOS14.0 when run chapter01

Jad2wizard opened this issue · comments

Describe the bug
When I run chapter01 samples with java -XstartOnFirstThread -jar target/chapter-01-1.0.0.jar .
I got this error:
截屏2024-01-20 11 35 59

I'm new to Java, so I don't know if where is some library missing? Should I install other java library?

Thanks

Please complete the following information):

  • OS: macOS 14.0
  • Java version [21.0.1]

Additional context
Add any other context about the problem here.

Ok, the application is not finding native libraries. First question: Are you includeing native jars ? In your case I guess it should be called "lwjgl-vma-3.3.3-natives-macos.jar". These dependencies are included in the maven project. Maybe you tried the code without using maven?

If that is not the case, you can try enabling LWJGL debuggining by setting the JVM argument: "-Dorg.lwjgl.util.Debug=true". It will provide useful information on how it is trying to load the lib. If you are having problems with setting this parameter, you can enable by code by setting this line: System.setProperty("org.lwjgl.util.Debug", "true"); as the very first line of the program.

Sorry, I missed something to report.
In fact, I executed mvn install with maven@3.6.3 in the root of booksamples before run chapter01.
The content of chapter01/target is
截屏2024-01-21 11 52 04
which includes the file "lwjgl-vma-3.3.3-natives-macos.jar"

After executing this command java -XstartOnFirstThread -Dorg.lwjgl.util.Debug=true -jar target/chapter-01-1.0.0.jar, I got these info

[LWJGL] Version: 3.3.3+5
	 OS: Mac OS X v14.0
	JRE: macOS x86_64 21.0.1
	JVM: Java HotSpot(TM) 64-Bit Server VM v21.0.1+12-LTS-29 by Oracle Corporation
[LWJGL] Loading JNI library: lwjgl
	Module: org.lwjgl
	Loaded from org.lwjgl.librarypath: /var/folders/t0/0rhw7ycx2cl2cjgb9drn6x640000gn/T/lwjgl_yaojia/3.3.3+5/x64/liblwjgl.dylib
[LWJGL] Loading library: glfw
	Module: org.lwjgl.glfw
	Loaded from org.lwjgl.librarypath: /var/folders/t0/0rhw7ycx2cl2cjgb9drn6x640000gn/T/lwjgl_yaojia/3.3.3+5/x64/libglfw.dylib
[LWJGL] Loading library: objc
	Module: org.lwjgl
	libobjc.dylib not found in org.lwjgl.librarypath=/var/folders/t0/0rhw7ycx2cl2cjgb9drn6x640000gn/T/lwjgl_yaojia/3.3.3+5/x64
[LWJGL] Warning: Failed to instantiate memory allocator: org.lwjgl.system.jemalloc.JEmallocAllocator. Using the system default.
[LWJGL] MemoryUtil allocator: StdlibAllocator
[LWJGL] Java 9 text decoding enabled
	Loaded from system paths: /usr/lib/libobjc.A.dylib
[LWJGL] Loading library: MoltenVK
	Module: org.lwjgl.vulkan
	libMoltenVK.dylib not found in org.lwjgl.librarypath=/var/folders/t0/0rhw7ycx2cl2cjgb9drn6x640000gn/T/lwjgl_yaojia/3.3.3+5/x64
	libMoltenVK.dylib not found in java.library.path=/Users/yaojia/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
	libMoltenVK.dylib not found in system paths
[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] Loading library: libvulkan.1.dylib
	Module: org.lwjgl.vulkan
	libvulkan.1.dylib not found in org.lwjgl.librarypath=/var/folders/t0/0rhw7ycx2cl2cjgb9drn6x640000gn/T/lwjgl_yaojia/3.3.3+5/x64
[LWJGL] Java 10 multiplyHigh enabled
	libvulkan.1.dylib not found in system paths
	libvulkan.1.dylib not found in java.library.path=/Users/yaojia/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
[LWJGL] Failed to load a library. Possible solutions:
	a) Install the library or the driver that provides the library.
	b) Ensure that the library is accessible from the system library paths.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: libvulkan.1.dylib
	at org.lwjgl.system.Library.loadNative(Library.java:346)
	at org.lwjgl.system.Library.loadNative(Library.java:236)
	at org.lwjgl.system.Library.loadNative(Library.java:217)
	at org.lwjgl.vulkan.VK.create(VK.java:70)
	at org.lwjgl.vulkan.VK.<clinit>(VK.java:37)
	at org.lwjgl.glfw.GLFWVulkan.<clinit>(GLFWVulkan.java:45)
	at org.vulkanb.eng.Window.<init>(Window.java:27)
	at org.vulkanb.eng.Window.<init>(Window.java:19)
	at org.vulkanb.eng.Engine.<init>(Engine.java:16)
	at org.vulkanb.Main.main(Main.java:12)

Should I download these libs which not found?

(EDITED)
Hi,

You are highlighting VMA natives, but you are missing lwjgl-vulkan-3.3.3-natives-macos.jar. This is the one that contains the missing libs. I was reviewing pom files and that file is indeed missing for all the chapters!

The thing is that jar is only needed for for macos. This is why I did not notice that. I will upload a fix immediately.

Sorry for the issue and thanks for reporting.

Already uploaded a fix. Please let me know if this works

Thanks, its work.