原文: https://blog.csdn.net/lunarych/article/details/107835522
网上找了很多mac的解决方案都是要设置DYLD_LIBRARY_PATH或者java.library.path,但是都没用,在GitHub上找到的答案:
原因:https://github.com/Z3Prover/z3/issues/294
Java是受SIP保护的可执行文件,它会忽略用户设置 DYLD_LIBRARY_PATH
Proof by running: /bin/ls -lO $(which java)
libz3.dylib 不在操作系统OS X的标准位置之一 : not in ~/lib, /usr/local/lib, /usr/lib
所以快速解决方案是移动或链接 libz3.dylib 到 ~/lib.
put JNI dynamic link libraries in: /Library/Java/Extensions
e.g.libz3java.dylib
put none-JNI dynamic link libraries in: /usr/local/lib
e.g. libz3.dylib
即:将libz3java.dylib放到 /Library/Java/Extensions中,libz3.dylib放到/usr/local/lib中
https://github.com/Z3Prover/z3/issues/4979
Hi,
I’m using z3 java bindings in a project (https://github.com/uclid-org/uclid) on Big Sur 11.1, and I think I am running into issue #294 again:
I’ve tried the solution in that thread, which worked on my intel mac on Mojave and Catalina with openJDK11 (and also openJDK8 but it didn’t work with a later version of openJDK):
put JNI dynamic link libraries in: /Library/Java/Extensions
e.g. libz3java.dylib
put none-JNI dynamic link libraries in: /usr/local/lib
e.g. libz3.dylib
As far as I can tell, this solution doesn’t work on BigSur and I get the error:
Exception in thread “main” java.lang.UnsatisfiedLinkError: no libz3java in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1875)
at java.lang.Runtime.loadLibrary0(Runtime.java:872)
The only way I can fix this error is to put libz3.dylib in the same directory that I call the binary from (I can leave libz3java.dylib in /Libary/Java/Extensions).
I’ve recreated this on two different setups:
• BigSur 11.1 on an M1 macbook, with zulu openjdk version 1.8.0_282 , and z3 4.8.11
• BigSur 11.1 on an intel macbook with AdoptOpenJDK11 and z3 4.8.8
Has anyone else encountered this and got a solution?
我的解决方案是直接在项目根目录 . 下添加 libz3java.dylib libz3.dylib
因为报错信息显示 /Library/Java/Extensions /usr/local/lib . 等目录缺少上述两个文件