Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnsatisfiedLinkError: Can't load library

My Mac ARM Laptop is failing to load the second library below:

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
        System.load("/Users/orlando/libbinaryen.dylib");
        System.load("/Users/orlando/libfingerprints.dylib");
    }
}

>> Hello world!
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /Users/orlando/libfingerprints.dylib
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
    at java.base/java.lang.Runtime.load0(Runtime.java:755)
    at java.base/java.lang.System.load(System.java:1953)
    at Main.main(Main.java:9)

I've tried both a library I've built and a library someone else built on their ARM Mac that works on their machine (and someone else's). Nobody can figure out why this is happening.

We've confirmed file permissions, file location, processor type, etc. We've also tried various debugging / output attempts like

java -Djava.library.path=/Users/orlando/Git/lib -verbose:jni -classpath /Users/orlando/Git/HelloWorld/out/production/HelloWorld Main

:
[0.119s][debug][jni,resolve] [Dynamic-linking native method java.lang.Throwable.fillInStackTrace ... JNI]
Exception in thread "main" [0.119s][debug][jni,resolve] [Dynamic-linking native method java.lang.System.identityHashCode ... JNI]
java.lang.UnsatisfiedLinkError: Can't load library: /Users/orlando/libfingerprints.dylib
[0.120s][debug][jni,resolve] [Dynamic-linking native method java.lang.StackTraceElement.initStackTraceElements ... JNI]
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
    at java.base/java.lang.Runtime.load0(Runtime.java:755)
    at java.base/java.lang.System.load(System.java:1953)
    at Main.main(Main.java:9)

Can anyone suggest anything off the beaten path I can try or verify?

Thanks in advance...

Extra information:

>> file libfingerprints.dylib
libfingerprints.dylib: Mach-O 64-bit dynamically linked shared library arm64

>> otool -L libfingerprints.dylib
libfingerprints.dylib:
  @rpath/libfingerprints.dylib (compatibility version 0.0.0, current version 0.0.0)
  /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1500.65.0)
  /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)

>> uname -m arm64

>> java --version
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS, mixed mode, sharing)
like image 418
Orlando Avatar asked Aug 12 '26 17:08

Orlando


1 Answers

Posting an unsatisfying answer, but sometimes you have to move on in life.

For reasons I don't understand, the issue resolved itself after uninstalling Correto Java 17 and installing OpenJDK 17 via Homebrew. This is puzzling because our production instance uses Correto, and another developer who has no issues with this is using Correto (albeit on an Intel based Mac). Maybe this is an issue with Correto on a Mac Arm or maybe just the act of reinstalling fixed things on it's own.

like image 87
Orlando Avatar answered Aug 15 '26 06:08

Orlando



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!