Linux通过JNI加载动态so链接出现java.lang.UnsatisfiedLinkError异常解决
在Linux环境使用JNI加载动态链接库中提供的本地方法时,经常会出现java.lang.UnsatisfiedLinkError,主要原因就是动态链接库对依赖库的路径查找范围中并不包括当前路径,一般会包括LD_LIBRARY_PATH环境变量的路径以及/etc/ld.so.conf中配置的路径,以及默认的路径比如/usr/lib和/usr/lib64。更新/etc/ld.so.conf之后需要执行ldconfig命令更新链接库缓存。
另外通过执行ldd命名,可以进行测试,如果没有出现依赖not found,说明一般没有问题:
[root@UAPTEST-WEB1-214 uapweb]# ldd libKCBPCliJNI.so ldd: warning: you do not have execution permission for `./libKCBPCliJNI.so' linux-vdso.so.1 => (0x00007fff235ff000) libkcbpcli.so => /usr/lib64/uapweb/libkcbpcli.so (0x00007f53b8e57000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f53b8c53000) libkcxpmq.so => /usr/lib64/uapweb/libkcxpmq.so (0x00007f53b8a0c000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f53b8706000) libm.so.6 => /lib64/libm.so.6 (0x00007f53b8482000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f53b826b000) libc.so.6 => /lib64/libc.so.6 (0x00007f53b7ed8000) libkcbpcrypt.so => /usr/lib64/uapweb/libkcbpcrypt.so (0x00007f53b7ccd000) /lib64/ld-linux-x86-64.so.2 (0x000000331a600000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f53b7aaf000)
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20