mirror of
https://github.com/Z3Prover/z3
synced 2026-06-10 10:57:15 +00:00
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>
This commit is contained in:
parent
0cc04b53eb
commit
2ed4e90c75
4 changed files with 59 additions and 7 deletions
|
|
@ -631,7 +631,16 @@ def mk_java(java_src, java_dir, package_name):
|
|||
java_native.write(' try {\n')
|
||||
java_native.write(' System.loadLibrary("z3java");\n')
|
||||
java_native.write(' } catch (UnsatisfiedLinkError ex) {\n')
|
||||
java_native.write(' System.loadLibrary("libz3java");\n')
|
||||
java_native.write(' try {\n')
|
||||
java_native.write(' System.loadLibrary("libz3java");\n')
|
||||
java_native.write(' } catch (UnsatisfiedLinkError ex2) {\n')
|
||||
java_native.write(' throw new UnsatisfiedLinkError(\n')
|
||||
java_native.write(' "Failed to load z3java native library. "\n')
|
||||
java_native.write(' + "Tried z3java: " + ex.getMessage() + "; "\n')
|
||||
java_native.write(' + "Tried libz3java: " + ex2.getMessage() + ". "\n')
|
||||
java_native.write(' + "Make sure both the JNI library and libz3 are in java.library.path "\n')
|
||||
java_native.write(' + "or set DYLD_LIBRARY_PATH (macOS) / LD_LIBRARY_PATH (Linux).");\n')
|
||||
java_native.write(' }\n')
|
||||
java_native.write(' }\n')
|
||||
java_native.write(' }\n')
|
||||
java_native.write(' }\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue