I was trying to export .jar file of my lwjgl game so I can send it to my friend using gradle. When I've opened jar in /build/libs via typing java -jar [name of file] this error message appear:
[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: liblwjgl.so
at org.lwjgl.system.Library.loadSystem(Library.java:164)
at org.lwjgl.system.Library.loadSystem(Library.java:63)
at org.lwjgl.system.Library.<clinit>(Library.java:51)
at org.lwjgl.system.MemoryUtil.<clinit>(MemoryUtil.java:100)
at org.lwjgl.system.Pointer$Default.<clinit>(Pointer.java:67)
at org.lwjgl.system.Callback.<clinit>(Callback.java:40)
at org.example.app.Engine.init(Engine.kt:64)
at org.example.app.Engine.run(Engine.kt:53)
at org.example.app.ApplicationKt.main(Application.kt:4)
at org.example.app.ApplicationKt.main(Application.kt)
I know that this kinda says what I need to do, but I don't really understand where should I add for example "-Djava.library.path".
here's my build.gradle
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.5.30'
}
group 'org.example'
version '1.0-SNAPSHOT'
project.ext.lwjglVersion = "3.3.0"
project.ext.lwjglNatives = "natives-linux"
repositories {
mavenCentral()
}
dependencies {
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
implementation 'org.joml:joml:1.10.3'
implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-assimp"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-openal"
implementation "org.lwjgl:lwjgl-opengl"
implementation "org.lwjgl:lwjgl-stb"
runtimeOnly "org.lwjgl:lwjgl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-assimp::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-glfw::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
}
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
manifest {
attributes 'Main-Class': 'org.example.app.ApplicationKt'
} from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
}
sourceSets {
main {
resources {
srcDir 'src/../lib'
}
}
}
gradle.properties:
kotlin.code.style=official
org.gradle.jvmargs=-Dkotlin.daemon.jvm.options=--illegal-access=permit
It works perfectly fine in IntelliJ, it gives an error only when trying to open outside of the IDE.
If it matters I'm using linux (POP_OS) and I'm writing this game in kotlin.