SpaiR / imgui-java

JNI based binding for Dear ImGui
MIT License
551 stars 90 forks source link

Bug: Library not found for Arch64 #165

Open FaultyxDx opened 1 year ago

FaultyxDx commented 1 year ago

Version

1.86.9

What happened?

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/~~aPFq1K5IGZtPglACKE1Dzw==/xyz.akatski.imguijni-G8FAKsF_TBczARNP_Fv6Hw==/lib/arm64/libimgui-java64.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)

Reproduction

i just loaded the sample code is provided in repo and compiled dependency in my application

Relevant log output

No response

SpaiR commented 1 year ago

Unfortunately, binding doesn't provide builds for arm/arch architectures.

ds58 commented 1 year ago

I would really like to have arm64 builds for macOS since that is a fairly common platform out there now.

phraktle commented 1 year ago

I would also prefer to use this natively. In the meantime, you can install an x86 JVM which will run with Rosetta.

kles4enko commented 1 year ago

+1

phraktle commented 1 year ago

some projects started using zig for easy cross-compilation of C code, eg. https://github.com/lmdbjava/lmdbjava/pull/217 I suspect this would work C++ as well, see https://zig.news/kristoff/cross-compile-a-c-c-project-with-zig-3599

LawrenceB5477 commented 9 months ago

+1

felouataoui commented 5 months ago

190 should solve this, but for anyone who wants a quick and dirty solution for Apple Silicon:

  1. Clone this repository
  2. Go to buildSrc/src/main/groovy/tool/generator/GenerateLibs.groovy
  3. Apply the following changes so you can target arm64:
    - def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true)
    + def mac64 = BuildTarget.newDefaultTarget(BuildTarget.TargetOs.MacOsX, true, true)
    - BuildExecutor.executeAnt(jniDir + '/build-macosx64.xml', commonParams)
    + BuildExecutor.executeAnt(jniDir + '/build-macosxarm64.xml', commonParams)
  4. From the repository root, build a native library for arm64: (you might have to install ant)
    ./gradlew imgui-binding:generateLibs -Denvs=macos -Dfreeetype=true -Dlocal
  5. You'll find the native library under imgui-binding/build/libsNative/macosxarm64/libimgui-javaarm64.dylib
  6. When starting your application pass the following JVM options:
    -Dimgui.library.path=./path/to/library/folder -Dimgui.library.name=libimgui-javaarm64.dylib
  7. Don't forget to also add the LWJGL native librariess for arm64 to your classpath