graalvm / native-build-tools

Native-image plugins for various build tools
https://graalvm.github.io/native-build-tools/
Other
366 stars 57 forks source link

[QUESTION] #517

Closed nkiesel closed 1 year ago

nkiesel commented 1 year ago

Describe the problem I am trying to use GraalVM-17 together with Kotlin 1.9.10 for MAC_OS on aarch64. Both the direct invocation of nativeCompile and the usage of the plugin result in the following error:

Finished generating 'CertificateHelper' in 58.5s.
[native-image-plugin] Native Image written to: /Users/norbert.kiesel/work/CertificateHelper/build/native/nativeCompile

> Task :nativeRun FAILED
Exception in thread "main" java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/darwin-aarch64/libjnidispatch.jnilib) not found in resource path ()
        at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1059)
        at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1015)
        at com.sun.jna.Native.<clinit>(Native.java:221)
        at com.github.ajalt.mordant.internal.MacosMppImpls.<init>(JnaMppImplsMacos.kt:46)
        at com.github.ajalt.mordant.internal.MppImplKt.<clinit>(MppImpl.kt:98)
        at com.github.ajalt.mordant.terminal.TerminalDetection.isJediTerm(TerminalDetection.kt:143)
        at com.github.ajalt.mordant.terminal.TerminalDetection.isIntellijRunActionConsole(TerminalDetection.kt:169)
        at com.github.ajalt.mordant.terminal.TerminalDetection.detectTerminal(TerminalDetection.kt:16)
        at com.github.ajalt.mordant.terminal.StdoutTerminalInterface.<init>(StdoutTerminalInterface.kt:17)
        at com.github.ajalt.mordant.terminal.Terminal.<init>(Terminal.kt:56)
        at com.github.ajalt.mordant.terminal.Terminal.<init>(Terminal.kt:45)
        at CertificateHelper.<init>(CertificateHelper.kt:147)
        at CertificateHelperKt.main(CertificateHelper.kt:92)

The JAR file from which the image is built does contain the native library:

% jar tf build/libs/CertificateHelper-2.2.0-uber.jar| rg com/sun/jna/darwin-aarch64/libjnidispatch.jnilib
4429:com/sun/jna/darwin-aarch64/libjnidispatch.jnilib

Additional context Add any other context about the problem here.

System Info (please complete the following information):

dnestoro commented 1 year ago

What is the actual question?

nkiesel commented 1 year ago

The question is: what do I have to do to avoid the "UnsatisfiedLinkError" related to "com/sun/jna/darwin-aarch64/libjnidispatch.jnilib"? Am I missing some steps or configuration options, or is this simply currently expected to fail on MacOS with ARM64?

olpaw commented 1 year ago

or is this simply currently expected to fail on MacOS with ARM64?

We do not have specific support for linking with libjnidispatch.jnilib in native-image right now.

But could it be that you are just missing the right resource configuration to ensure that com/sun/jna/darwin-aarch64/libjnidispatch.jnilib is available at image runtime? Running your application on the JVM with the native-image-agent might be able to produce such a configuration file for you. See https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/AutomaticMetadataCollection.md

Since this issue is not about native-build-tools but about image building in general I'm closing this issue here. If you need further support please open a ticket at https://github.com/oracle/graal/issues