error while loading shared libraries解决办法
2016-08-17 18:37
429 查看
error while loading shared libraries: librdkafka++.so.1: cannot open shared object file: No such file or directory 解决办法
1,cd /etc/
2,sudo ldconfig
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*********************** over****************************/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
出错如下:
主要错误:error while loading shared libraries: libboost_regex.so.1.51.0: cannot open shared object file: No such file or directory
错误过程如下:
[cpp] view
plain copy
[root@node07 C++]# ll
总用量 960
-rw-r--r--. 1 root root 90915 9月 15 20:47 1.html
-rw-r--r--. 1 root root 86714 9月 15 20:48 2.html
-rw-r--r--. 1 root root 89032 9月 15 20:49 3.html
-rw-r--r--. 1 root root 239 9月 16 10:40 main.cpp
-rw-r--r--. 1 root root 5684 9月 16 10:48 main.o
-rw-r--r--. 1 root root 320 9月 16 10:28 Makefile
-rwxr-xr-x. 1 root root 256884 9月 16 10:48 target
-rw-r--r--. 1 root root 0 9月 15 20:49 test.txt
-rw-r--r--. 1 root root 4365 9月 15 20:35 TextExtractor.cpp
-rw-r--r--. 1 root root 1710 9月 15 20:58 TextExtractor.h
-rw-r--r--. 1 root root 421412 9月 16 10:48 TextExtractor.o
[root@node07 C++]# ./target
./target: error while loading shared libraries: libboost_regex.so.1.51.0: cannot open shared object
file: No such file or directory
那就表示系统不知道xxx.so放在哪个目录下,这个时候就要在/etc/ld.so.conf中加入xxx.so所在的目录。首先查找存在的目录,结果为/usr/local/boost_1_51_0/~/boost_install/lib/,具体操作如下:
[cpp] view
plain copy
[root@node07 C++]# find / -name libboost_regex.*
/usr/local/boost_1_51_0/bin.v2/libs/regex/build/gcc-4.4.5/release/threading-multi/libboost_regex.so.1.51.0
/usr/local/boost_1_51_0/bin.v2/libs/regex/build/gcc-4.4.5/release/link-static/threading-multi/libboost_regex.a
/usr/local/boost_1_51_0/~/boost_install/lib/libboost_regex.so.1.51.0
/usr/local/boost_1_51_0/~/boost_install/lib/libboost_regex.so
/usr/local/boost_1_51_0/~/boost_install/lib/libboost_regex.a
一般而言,有很多so档会在/usr/local/lib这个目录下,所以在/etc/ld.so.conf中加入/usr/local/lib这一行,可以解决此问题。
将/etc/ld.so.conf存档后,还要执行/etc/ldconfig 来更新一下才会生效。
[cpp] view
plain copy
[root@node07 C++]# cd /etc/
[root@node07 etc]# ldconfig
再次运行target 无错误。
1,cd /etc/
2,sudo ldconfig
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*********************** over****************************/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
出错如下:
主要错误:error while loading shared libraries: libboost_regex.so.1.51.0: cannot open shared object file: No such file or directory
错误过程如下:
[cpp] view
plain copy
[root@node07 C++]# ll
总用量 960
-rw-r--r--. 1 root root 90915 9月 15 20:47 1.html
-rw-r--r--. 1 root root 86714 9月 15 20:48 2.html
-rw-r--r--. 1 root root 89032 9月 15 20:49 3.html
-rw-r--r--. 1 root root 239 9月 16 10:40 main.cpp
-rw-r--r--. 1 root root 5684 9月 16 10:48 main.o
-rw-r--r--. 1 root root 320 9月 16 10:28 Makefile
-rwxr-xr-x. 1 root root 256884 9月 16 10:48 target
-rw-r--r--. 1 root root 0 9月 15 20:49 test.txt
-rw-r--r--. 1 root root 4365 9月 15 20:35 TextExtractor.cpp
-rw-r--r--. 1 root root 1710 9月 15 20:58 TextExtractor.h
-rw-r--r--. 1 root root 421412 9月 16 10:48 TextExtractor.o
[root@node07 C++]# ./target
./target: error while loading shared libraries: libboost_regex.so.1.51.0: cannot open shared object
file: No such file or directory
那就表示系统不知道xxx.so放在哪个目录下,这个时候就要在/etc/ld.so.conf中加入xxx.so所在的目录。首先查找存在的目录,结果为/usr/local/boost_1_51_0/~/boost_install/lib/,具体操作如下:
[cpp] view
plain copy
[root@node07 C++]# find / -name libboost_regex.*
/usr/local/boost_1_51_0/bin.v2/libs/regex/build/gcc-4.4.5/release/threading-multi/libboost_regex.so.1.51.0
/usr/local/boost_1_51_0/bin.v2/libs/regex/build/gcc-4.4.5/release/link-static/threading-multi/libboost_regex.a
/usr/local/boost_1_51_0/~/boost_install/lib/libboost_regex.so.1.51.0
/usr/local/boost_1_51_0/~/boost_install/lib/libboost_regex.so
/usr/local/boost_1_51_0/~/boost_install/lib/libboost_regex.a
一般而言,有很多so档会在/usr/local/lib这个目录下,所以在/etc/ld.so.conf中加入/usr/local/lib这一行,可以解决此问题。
将/etc/ld.so.conf存档后,还要执行/etc/ldconfig 来更新一下才会生效。
[cpp] view
plain copy
[root@node07 C++]# cd /etc/
[root@node07 etc]# ldconfig
再次运行target 无错误。
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- c++11 + SDL2 + ffmpeg +OpenAL + java = Android播放器
- 关于指针的一些事情
- 在Windows平台下使用安装GCC(图)
- c++ primer 第五版 笔记前言
- share_ptr的几个注意点
- Lua中调用C++函数示例
- Lua教程(一):在C++中嵌入Lua脚本
- Lua教程(二):C++和Lua相互传递数据示例
- C++联合体转换成C#结构的实现方法
- C++高级程序员成长之路
- C++编写简单的打靶游戏
- C++ 自定义控件的移植问题
- C++变位词问题分析
- C/C++数据对齐详细解析
- C++基于栈实现铁轨问题
- C++中引用的使用总结
- 使用Lua来扩展C++程序的方法
- C++中调用Lua函数实例