「cannot open shared object file」的解決方案
来源:互联网 发布:游戏辅助软件制作 编辑:程序博客网 时间:2024/06/15 17:08
有時候執行一些指令,會碰到下面這樣的訊息:
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
在這個例子中,我們的程式找不到 libiconv.so.2
這個 dynamic library。那麼應該怎麼解決呢?
首先必須找到系統中的 libiconv.so.2
,下面四條指令選一條作就好:
$ locate libiconv.so.2$ whereis libiconv.so.2$ find /usr /lib -name libiconv.so.2$ find / -name libiconv.so.2 2>/dev/null
這時候就可以找出函式庫位置,例如:
/usr/local/lib/libiconv.so
萬一沒有找出來的話,就要自行安裝了。這篇文章有教該如何安裝 libiconv,如果是其他函式庫的話可以自行變通。
找到位置之後,應該怎麼做呢?如果我們有 root 權限的話,可以把函式庫所在路徑寫入 /etc/ld.so.conf
,再重新產生 ld 的 cache 即可,如下:
# echo "/usr/local/lib" >> /etc/ld.so.conf # 注意! 要用 >> 而非 >!# ldconfig
在某些系統中,/etc/ld.so.conf
可能會預設加上 include /etc/ld.so.conf.d/*.conf
這樣的敘述,那們我們也可以把路徑放在那個目錄下:
# echo "/usr/local/lib" >> /etc/ld.so.conf.d/usr_local_lib.conf# ldconfig
這樣一來就可以讓程式順利搜尋到需要的 library 囉!
BUT!! 玩 Linux 最重要的就是這個 BUT!!
如果我們沒有 root 權限的話該怎麼辦呢?這時候只好很可憐的自己搞定了...如果需要自行編譯 library 的話,可以照著類似的步驟做,但是 prefix (也就是安裝位置) 要設定在自己的家目錄下,例如:
$ ./configure --prefix=$HOME/libiconv
但這邊假設系統中已經有 /usr/local/lib/libiconv.so.2
這個檔案,進行以下步驟:
$ echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
原理很簡單,就是透過設定 LD_LIBRARY_PATH
來讓程式找得到需要的 library 檔案。修改後需要重新登入才會生效喔!
但是...基本上還是建議不要用後面這個方法啦,找你的系統管理員協助設定 /etc/ld.so.conf
才是好主意。這裡有篇文章:Why LD_LIBRARY_PATH is bad,專門在討論為什麼不要隨意使用LD_LIBRARY_PATH
。
- 「cannot open shared object file」的解決方案
- cannot open shared object file
- cannot open shared object file 问题的解决
- libESR_Shared.so: cannot open shared object file
- Glog "libglog cannot open shared object file"
- cannot open shared object file问题解决办法
- fedora20 执行 arm-linux-gcc 出现 libz.so.1: cannot open shared object file问题解决方案
- error while loading shared libraries cannot open shared object file
- error while loading shared libraries| cannot open shared object file
- Error While Loading Shared Libraries, Cannot Open Shared Object File
- Error While Loading Shared Libraries, Cannot Open Shared Object File
- error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: 的解决办法
- 动态库的动态链接(error while loading shared libraries,cannot open shared object file)
- error while loading shared libraries: xxx.so.0:cannot open shared object file:的错误解决
- cannot open shared object file: No such file or directory
- cannot open shared object file: No such file or directory
- cannot open shared object file: No such file or directory
- python: cannot open shared object file: No such file
- 欢迎使用CSDN-markdown编辑器
- hbase建表时region预分区的方法
- java设计模式进阶_model-view-presenter
- for循环的执行顺序
- 无人机Mavlink+offboard模式指令概述
- 「cannot open shared object file」的解決方案
- UVA11551-Experienced Endeavour
- why 'not in' can not be followed with 'null'
- 自定义导航
- struts2中Action
- csu1811 Tree Intersection(线段树合并)★ ★ ★
- Nginx常用命令
- 一些名企秋招网申链接合集
- 实验楼Linux学习笔记(三)之 目录结构及文件基本操作