場景, 在Spring Boot加載so文件, 在此記錄配置的過程和幫助過我的鏈接文檔
System.loadLibrary("hello"); // Load native library at runtime
hello.dll (Windows) or libhello.so
注意: window環境中文件名為hello.dll 或 libhello.so
步驟1: 把so文件存放在一個目錄中
步驟2: Linux 運行jar文件配置lib庫地址
nohup java -Dfile.encoding=utf-8 -Djava.library.path=/root/baller/lib -jar picture-server.jar >nohup.log 2>&1 &
此時運行會提示錯誤: cannot open shared object file: No such file or directory
步驟3: 把非lib目錄 加入到共享庫配置文件/etc/ld.so.conf 中
參考地址: https://blog.csdn.net/chen495810242/article/details/89314570
# cat /etc/ld.so.conf include ld.so.conf.d/*.conf # echo "/root/baller/lib" >> /etc/ld.so.conf # ldconfig 刷新的作用
步驟4: 再次執行jar 啟動,成功無錯誤