Search code examples
javajava-native-interfacemacos-catalinasolace

OSX UnsatisfiedLinkErrors run JNI-wrapped library on OSX catalina 10.15.x


Ever since upgrading to OSX Catalina I've been having issues with UnsatisfiedLinkErrors trying to run a JNI-wrapped library under java with multiple native library references which successfully ran under earlier OSX versions:

export DYLD_LIBRARY_PATH=/path/to/solclientj/lib:$DYLD_LIBRARY_PATH
java -cp /path/to/target/classes:<snip classpath> -Djava.library.path=/path/to/solclientj/lib com.example.demo.MockMatchingEngine <arguments...>

Jan 30, 2020 12:53:56 PM com.solacesystems.solclientj.core.impl.util.SolLogger critical
SEVERE: solclient_jni failed to load : /path/to/solclientj/lib/libsolclient_jni.dylib: dlopen(/path/to/solclientj/lib/libsolclient_jni.dylib, 1): Library not loaded: libsolclient.so.1
  Referenced from: /path/to/solclientj/lib/libsolclient_jni.dylib
  Reason: image not found
java.lang.UnsatisfiedLinkError: /path/to/solclientj/lib/libsolclient_jni.dylib: dlopen(/path/to/solclientj/lib/libsolclient_jni.dylib, 1): Library not loaded: libsolclient.so.1
  Referenced from: /path/to/solclientj/lib/libsolclient_jni.dylib
  Reason: image not found

Whereas, if a cd into /path/to/solclientj and execute the commandline from there it runs successfully. Any clues as to why it finds libs in the current directory but apparently not when they're on the DYLD_LIBRARY_PATH? Because it does seem to be finding the top-level libsolclient_jni.dylib via DYLD_LIBRARY_PATH, it's only the referenced libsolclient.so.1 from the same directory that is not being found.

Thanks for any interesting info.


Solution

  • SOLVED: It was OSX System Integrity Protection (SIP). This caused scripts/subshells/subprocesses to lose all the environment of the caller, thus nuking my DYLD_LIBRARY_PATH.

    https://www.macworld.com/article/2986118/how-to-modify-system-integrity-protection-in-el-capitan.html