靜態庫路徑配置
阿新 • • 發佈:2018-04-20
strong ann .com linux共享 tor rect 保存 libraries object
存在問題:
編譯高博《視覺SLAM十四講》的第六講g2o_curve_fitting時,從thirdparty安裝了g2o後,運行程序出現: error while loading shared libraries: libg2o_core.so: cannot open shared object file: No such file for directory問題原因:
在默認情況下,編譯器只會使用/lib和/usr/lib這兩個目錄下的庫文件,通過源碼包進行安裝時,如果不指定--prefix會將庫安裝在/usr/local目錄下,而又沒有在文件/etc/ld.so.conf中添加 /usr/local/lib這個目錄。這樣雖然安裝了源碼包,但是使用時仍然找不到相關的.so庫,就會報錯。也就是說系統不知道安裝了源碼包。解決方法:
在/etc/ld.so.conf中添加絕對路徑/usr/local/lib
具體步驟:
1.用gedit打開/etc/ld.so.conf文件,添加內容:/usr/local/lib,由於不能直接保存,將此文件另存到home目錄下。 2.在home目錄下sudo cp -i ld.so.conf /etc/ld.so.conf //將原本的/etc/ld.so.conf文件覆蓋
sudo ldconfg //利用ldconfg執行文件將/etc/ld.so.conf的數據讀入高速緩存中
結果:
再次運行./g2o_curve_fitting 成功。
網絡資源:
linux共享庫,以及/etc/ld.so.conf文件的應用 (http://blog.csdn.net/oathevil/article/details/13564213)
/etc/ld.so.conf 文件介紹(http://blog.csdn.net/yjkwf/article/details/7545002)
/etc/ld.so.conf和ldconfig, PKG_CONFIG_PATH
(http://blog.csdn.net/allwtg/article/details/5145306)
https://www.cnblogs.com/gaoxiang12/p/4770813.html
靜態庫路徑配置