LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.75k stars 635 forks source link

Mac OS 13.1: libSystem.dylib not found #839

Closed rongcuid closed 1 year ago

rongcuid commented 1 year ago

Version

3.3.1

Platform

macOS arm64

JDK

Java HotSpot(TM) 64-Bit Server VM v17.0.4.1+1-LTS-2 by Oracle Corporation

Module

LWJGL Core

Bug description

I try to do a simple LWJGL project, but on glfwInit I get the following error. It seems related to MacOS dynamic library. I will try to provide a minimal example if needed, but I think just calling glfwInit() suffices.

Stacktrace or crash log output

[LWJGL] Version: 3.3.1 build 7
[LWJGL]      OS: Mac OS X v13.1
[LWJGL]     JRE: macOS aarch64 17.0.4.1
[LWJGL]     JVM: Java HotSpot(TM) 64-Bit Server VM v17.0.4.1+1-LTS-2 by Oracle Corporation
[LWJGL] Loading JNI library: lwjgl
[LWJGL]     Module: org.lwjgl
[LWJGL]     Extracting: file:/Users/rongcuid/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.3.1/71d0d5e469c9c95351eb949064497e3391616ac9/lwjgl-3.3.1-natives-macos-arm64.jar!/macos/arm64/org/lwjgl/liblwjgl.dylib
[LWJGL]     Loaded from org.lwjgl.librarypath: /var/folders/tw/8vsfcypj5rx4gbst7z5nrj7c0000gn/T/lwjglrongcuid/3.3.1-build-7/liblwjgl.dylib
[LWJGL] Loading library: glfw
[LWJGL]     Module: org.lwjgl.glfw
[LWJGL]     Extracting: file:/Users/rongcuid/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-glfw/3.3.1/cac0d3f712a3da7641fa174735a5f315de7ffe0a/lwjgl-glfw-3.3.1-natives-macos-arm64.jar!/macos/arm64/org/lwjgl/glfw/libglfw.dylib
[LWJGL]     Loaded from org.lwjgl.librarypath: /var/folders/tw/8vsfcypj5rx4gbst7z5nrj7c0000gn/T/lwjglrongcuid/3.3.1-build-7/libglfw.dylib
[LWJGL] Loading library: objc
[LWJGL]     Module: org.lwjgl
[LWJGL]     libobjc.dylib not found in org.lwjgl.librarypath=/var/folders/tw/8vsfcypj5rx4gbst7z5nrj7c0000gn/T/lwjglrongcuid/3.3.1-build-7
[LWJGL] Loading library: jemalloc
[LWJGL]     Module: org.lwjgl.jemalloc
[LWJGL]     Extracting: file:/Users/rongcuid/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-jemalloc/3.3.1/e577b87d8ad2ade361aaea2fcf226c660b15dee8/lwjgl-jemalloc-3.3.1-natives-macos-arm64.jar!/macos/arm64/org/lwjgl/jemalloc/libjemalloc.dylib
[LWJGL]     Loaded from org.lwjgl.librarypath: /var/folders/tw/8vsfcypj5rx4gbst7z5nrj7c0000gn/T/lwjglrongcuid/3.3.1-build-7/libjemalloc.dylib
[LWJGL] MemoryUtil allocator: JEmallocAllocator
[LWJGL] Java 9 text decoding enabled
[LWJGL]     Loaded from system paths: /usr/lib/libobjc.A.dylib
[LWJGL] Loading library: System
[LWJGL]     Module: org.lwjgl
[LWJGL]     libSystem.dylib not found in org.lwjgl.librarypath=/var/folders/tw/8vsfcypj5rx4gbst7z5nrj7c0000gn/T/lwjglrongcuid/3.3.1-build-7
[LWJGL]     Loaded from system paths: /usr/lib/libSystem.B.dylib
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1046)
    at eng.Window.<init>(Window.kt:18)
    at eng.Window.<init>(Window.kt:10)
    at eng.Engine.<init>(Engine.kt:16)
    at MainKt.main(Main.kt:20)
Caused by: java.lang.IllegalStateException: GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.
    at org.lwjgl.glfw.EventLoop.<clinit>(EventLoop.java:30)
    ... 5 more
rongcuid commented 1 year ago

The crash is unrelated (me forgetting to set -XstartOnFirstThread), but the warning/error is still there

Spasi commented 1 year ago

Hey @rongcuid,

The LWJGL shared library loading mechanism is working as expected here, the message is confirming that LWJGL first looked in org.lwjgl.librarypath before trying the system paths. It's useful when troubleshooting library loading issues.

rongcuid commented 1 year ago

Oh, I thought it was an error