Fix Java UnsatisfiedLinkError on macOS (#7640)#9027
Conversation
On macOS, libz3java.dylib was built without an rpath to find libz3.dylib in the same directory. When Java loaded the JNI library, the dynamic linker could not resolve the libz3 dependency, causing UnsatisfiedLinkError. Three fixes: - mk_util.py: add -Wl,-rpath,@loader_path to the macOS JNI link command - CMakeLists.txt: set MACOSX_RPATH, BUILD_RPATH, INSTALL_RPATH for z3java target; remove duplicate headerpad block - update_api.py: improve Native.java error message to show the root cause from both load attempts instead of only the fallback error Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@sabrieker, can you please review this pull request? This is an AI generated request and I am not an expert here. |
|
@levnach - the PR adds functions to a file test_jni_... |
|
@NikolajBjorner, the file is here test_jni_arch_flags.py. ~/dev/z3/scripts/tests % git log test_jni_arch_flags.py |
On macOS, libz3java.dylib was built without an rpath to find libz3.dylib in the same directory. When Java loaded the JNI library, the dynamic linker could not resolve the libz3 dependency, causing UnsatisfiedLinkError.
Three fixes: