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.
Description:
When calling org.lwjgl.glfw.GLFW.glfwInit(), false is returned and a GLFW_PLATFORM_ERROR is thrown with it's description stating, that it failed to load libwayland-client.
Any help in resolving this would be greatly appreciated!
Steps To Reproduce:
Use a Linux system on Wayland
Run an application using LWJGL3
Observe the logs
Actual Behavior:
A following stack trace is printed and the program exists:
- Full example Logs from an application using LWJGL:
Task :SceneTest.main() FAILED
[ Info] Logging file at '/para/Projects/leEngine/javaengine/logs/2024-11-22-14-23-25 - 0.log'
[ Info] Setting up OpenGL and GLFW...
[ Debug] LWJGL Version: 3.3.4+7
[ Error] [LWJGL] GLFW_PLATFORM_ERROR error
Description : Wayland: Failed to load libwayland-client
Stacktrace :
org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1109)
org.app.core.GLManager.init(GLManager.java:31)
org.app.core.scene.SceneTest.main(SceneTest.java:38)
[ !Crit] Unable to initialize GLFW
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalAccessException: Unable to initialize GLFW
at org.app.utils.Logger.logAndThrow(Logger.java:126)
at org.app.utils.Logger.logAndThrow(Logger.java:131)
at org.app.core.GLManager.init(GLManager.java:32)
at org.app.core.scene.SceneTest.main(SceneTest.java:38)
Caused by: java.lang.IllegalAccessException: Unable to initialize GLFW
Caused by: java.lang.IllegalAccessException: Unable to initialize GLFW
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
... 3 more
Execution failed for task ':SceneTest.main()'.
Process 'command '/home/luh/.nix-profile/bin/java'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
EDIT:
Upgrading to Gradle 8.11.1 and Java 23 did not fix anything
EDIT 2:
When setting a hint to use X11, to try and run the application through xwayland (glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);) a similar thing happens:
Question
Description: When calling
org.lwjgl.glfw.GLFW.glfwInit()
, false is returned and aGLFW_PLATFORM_ERROR
is thrown with it's description stating, that it failed to loadlibwayland-client
.Any help in resolving this would be greatly appreciated!
Steps To Reproduce:
Actual Behavior: A following stack trace is printed and the program exists:
Expected Behavior: GLFW gets initialized and the program keeps running.
Environment:
Additional Context:
// Initialize GLFW if ( !glfwInit() ) // <---- Returns false Logger.logAndThrow("Unable to initialize GLFW", IllegalAccessException.class);
import org.gradle.internal.os.OperatingSystem
plugins { id 'java' id 'application' id 'c' }
group = 'org.app' version = '1.0-SNAPSHOT'
project.ext.lwjglVersion = "3.3.4"
switch (OperatingSystem.current()) { case OperatingSystem.FREE_BSD: project.ext.lwjglNatives = "natives-freebsd" break case OperatingSystem.LINUX: project.ext.lwjglNatives = "natives-linux" def osArch = System.getProperty("os.arch") if (osArch.startsWith("arm") || osArch.startsWith("aarch64")) { project.ext.lwjglNatives += osArch.contains("64") || osArch.startsWith("armv8") ? "-arm64" : "-arm32" } else if (osArch.startsWith("ppc")) { project.ext.lwjglNatives += "-ppc64le" } else if (osArch.startsWith("riscv")) { project.ext.lwjglNatives += "-riscv64" } break case OperatingSystem.MAC_OS: project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos" break case OperatingSystem.WINDOWS: def osArch = System.getProperty("os.arch") project.ext.lwjglNatives = osArch.contains("64") ? "natives-windows${osArch.startsWith("aarch64") ? "-arm64" : ""}" : "natives-windows-x86" break }
repositories { mavenCentral() maven { url "https://raw.githubusercontent.com/kotlin-graphics/mary/master" } }
dependencies { testImplementation platform('org.junit:junit-bom:5.9.1') testImplementation 'org.junit.jupiter:junit-jupiter'
}
test { useJUnitPlatform() }
[ !Crit] Unable to initialize GLFW Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalAccessException: Unable to initialize GLFW at org.app.utils.Logger.logAndThrow(Logger.java:126) at org.app.utils.Logger.logAndThrow(Logger.java:131) at org.app.core.GLManager.init(GLManager.java:32) at org.app.core.scene.SceneTest.main(SceneTest.java:38) Caused by: java.lang.IllegalAccessException: Unable to initialize GLFW Caused by: java.lang.IllegalAccessException: Unable to initialize GLFW
Execution failed for task ':SceneTest.main()'.
EDIT: Upgrading to Gradle 8.11.1 and Java 23 did not fix anything
EDIT 2: When setting a hint to use X11, to try and run the application through xwayland (
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11);
) a similar thing happens: