为什么我收到错误“java.lang.UnsatisfiedLinkError:无法加载库”什么时候可以找到该文件?
尽管文件明显存在并且可以读取,为什么我会收到此错误?
我的项目正在使用 lwjgl 和 imgui-java。我已将 -Dimgui.library.path="libs" (存储有问题的 .dylib 的位置)添加到我的 VM 选项中,并且应用程序应该打开,显示演示 IMGUI。
我还在下面发布了我的 build.gradle 文件:
plugins {
id 'java'
}
group 'org.tpsgames'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
import org.gradle.internal.os.OperatingSystem
project.ext.lwjglVersion = "3.3.1"
project.ext.jomlVersion = "1.10.4"
project.ext.imguiVersion = '1.86.4'
project.ext.lwjglNatives = "natives-macos"
switch (OperatingSystem.current()) {
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
break
}
repositories {
mavenCentral()
}
dependencies {
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
implementation "io.github.spair:imgui-java-app:1.86.4"
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
implementation fileTree('libs') {include '*.jar'}
['', '-opengl', '-glfw'].each {
implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
implementation "org.lwjgl:lwjgl$it::natives-macos"
}
implementation "io.github.spair:imgui-java-binding:1.86.4"
implementation "io.github.spair:imgui-java-lwjgl3:1.86.4"
implementation "io.github.spair:imgui-java-natives-macos:1.86.4"
implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-assimp"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-nfd"
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-nfd::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
implementation "org.joml:joml:1.10.4"
}
test {
useJUnitPlatform()
}
Why am I receiving this error even though the file is clearly there and it could be read?
My project is using lwjgl and imgui-java. I have added -Dimgui.library.path="libs" (where the .dylib in question is stored) to my VM options and the application should open, displaying the demo IMGUI.
I have also posted my build.gradle file below:
plugins {
id 'java'
}
group 'org.tpsgames'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
import org.gradle.internal.os.OperatingSystem
project.ext.lwjglVersion = "3.3.1"
project.ext.jomlVersion = "1.10.4"
project.ext.imguiVersion = '1.86.4'
project.ext.lwjglNatives = "natives-macos"
switch (OperatingSystem.current()) {
case OperatingSystem.MAC_OS:
project.ext.lwjglNatives = System.getProperty("os.arch").startsWith("aarch64") ? "natives-macos-arm64" : "natives-macos"
break
}
repositories {
mavenCentral()
}
dependencies {
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
implementation "io.github.spair:imgui-java-app:1.86.4"
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
implementation fileTree('libs') {include '*.jar'}
['', '-opengl', '-glfw'].each {
implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
implementation "org.lwjgl:lwjgl$it::natives-macos"
}
implementation "io.github.spair:imgui-java-binding:1.86.4"
implementation "io.github.spair:imgui-java-lwjgl3:1.86.4"
implementation "io.github.spair:imgui-java-natives-macos:1.86.4"
implementation "org.lwjgl:lwjgl"
implementation "org.lwjgl:lwjgl-assimp"
implementation "org.lwjgl:lwjgl-glfw"
implementation "org.lwjgl:lwjgl-nfd"
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-nfd::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-openal::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-opengl::$lwjglNatives"
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives"
implementation "org.joml:joml:1.10.4"
}
test {
useJUnitPlatform()
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的计算机很可能具有带有ARM架构的CPU,例如M1芯片,而不是X86架构。
因此,JVM进程无法加载IMGUI-JAVA64.DYLIB共享库,因为Imgui-Java当前仅船舶X86 CPU架构共享库,而不是ARM的库。
请参阅此GitHub问题: https://github.com/spair/spair/imgui-java/issues/ 123
此(当前打开)github拉请求: https://github.com/spair/spair/spair/imgui -java/pult/112 为IMGUI-JAVA添加ARM CPU支持。
您唯一的解决方案是可能将当前已完成的工作纳入该GitHub拉的请求中,并在本地为您的ARM CPU编译IMGUI-JAVA,或等到PR合并到合并PR并与MacOS Arm共享库的IMGui-Java船舶释放。
Your computer very likely has a CPU with the ARM architecture, such as the M1 chip, instead of the x86 architecture.
Therefore, the JVM process cannot load the imgui-java64.dylib shared library because imgui-java currently only ships x86 CPU architecture shared libraries, not ARM ones.
See this GitHub issue: https://github.com/SpaiR/imgui-java/issues/123
and this (currently open) GitHub Pull Request: https://github.com/SpaiR/imgui-java/pull/112 to add ARM CPU support for imgui-java.
Your only solution is to probably incorporate the work currently having been done in that GitHub Pull Request and compile imgui-java locally yourself for your ARM CPU or wait until the PR is merged and a release of imgui-java ships with macOS ARM shared libraries.