error while loading shared libraries: xxx.so.x" 错误的原因和解决办法
今天在执行一个protobuf程序时,提示error while loading shared libraries: libprotobuf.so.8: cannot open shared object file: No such file or directory错误。google了一下,是由于找不到lib这个文件。
解决办法:
一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如:
tmux: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib*.so.*文件)或者共享库版本不对, 遇到这种情况那就去网上下载并安装上即可.
另外一个原因就是已经安装了该共享库, 但执行需要调用该共享库的程序的时候, 程序按照默认共享库路径找不到该共享库文件.
所以安装共享库后要注意共享库路径设置问题, 如下:
1) 如果共享库文件安装到了/lib或/usr/lib目录下, 那么需执行一下ldconfig命令
ldconfig命令的用途, 主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下, 搜索出可共享的动态链接库(格式如lib*.so*), 进而创建出动态装入程序(ld.so)所需的连接和缓存文件. 缓存文件默认为/etc/ld.so.cache, 此文件保存已排好序的动态链接库名字列表.
2) 如果共享库文件安装到了/usr/local/lib(很多开源的共享库都会安装到该目录下)或其它"非/lib或/usr/lib"目录下, 那么在执行ldconfig命令前, 还要把新共享库目录加入到共享库配置文件/etc/ld.so.conf中, 如下:
# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
# echo "/usr/local/lib" >> /etc/ld.so.conf
# ldconfig
3) 如果共享库文件安装到了其它"非/lib或/usr/lib" 目录下, 但是又不想在/etc/ld.so.conf中加路径(或者是没有权限加路径). 那可以export一个全局变量LD_LIBRARY_PATH, 然后运行程序的时候就会去这个目录中找共享库.
LD_LIBRARY_PATH的意思是告诉loader在哪些目录中可以找到共享库. 可以设置多个搜索目录, 这些目录之间用冒号分隔开. 比如安装了一个mysql到/usr/local/mysql目录下, 其中有一大堆库文件在/usr/local/mysql/lib下面, 则可以在.bashrc或.bash_profile或shell里加入以下语句即可:
export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH
一般来讲这只是一种临时的解决方案, 在没有权限或临时需要的时候使用.
参考:
http://blog.csdn.net/sahusoft/article/details/7388617
http://www.360doc.com/content/10/0601/09/11991_30616166.shtml
相关文章
- MySQL 从 5.5 升级到 5.6,启动时报错 [ERROR] Plugin 'InnoDB' init function returned error
- opencv error: insufficient memory错误解决办法
- error while loading shared libraries: xxx.so.x" 错误的原因和解决办法
- loadrunner11 错误:Error -26377: No match found for the requested parameter XXXX. web_custom_request(XXX) highest severity level was "ERROR",....... [MsgId: MMSG-26387]
- 升级mysql_upgrade 提示错误FATAL ERROR: Upgrade failed的原因
- HTTP 错误 500.19 - Internal Server Error
- ORACLE中的Net Configuration Assistant 点击后无反应, sqlplus登录数据库提示Oracle11g ORA-12560: TNS: 协议适配器错误
- 向Oracle中插入记录时,出现“Oracle.DataAccess.Client.OracleException ORA-00933 ”错误
- SAP GUI 遇到 Error in Parser-Thread 错误的解决方法
- Angular 依赖注入错误消息:ERROR Error NullInjectorError No provider for XX
- 成功解决pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 48, saw 2
- git pull遇到错误:error: Your local changes to the following files would be overwritten by merge:
- mysql 函数执行错误-解决
- 解决登录druid监控首页时出现Whitelabel Error Page:There was an unexpected error (type=Not Found, status=404)的错误
- 完美解决导入from PIL import image出现错误的问题
- 无法识别的属性“targetFramework”。请注意,属性名是大写和小写。错误的解决方案
- 一些小错误
- 云计算|OpenStack|错误记录和解决方案(不定时更新)
- Linux|错误集锦|prometheus Error on ingesting samples that are too old or are too far into the future的解决
- 如何解决npm run serve运行vue项目时,出现报错:Error: error:0308010C:digital envelope routines::unsupported
- error while loading shared libraries: libgo.so.19 错误的解决