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()
}
CodePudding user response:
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.