编辑 vim /etc/ld.so.conf 将动态库目录添加进去,执行ldconfig即可
include ld.so.conf.d/*.conf
/root/poco/myPocoTest
刷新
sudo ldconfig
或者临时刷新
~$ LD_LIBRARY_PATH=/usr/local/lib
~$ export LD_LIBRARY_PATH
~$ g++ poco.cpp -lPocoNet
~$ ./a.out
[root@jn myPocoTest]# ./a.out
./a.out: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /root/poco/myPocoTest/libPocoFoundation.so.71)
./a.out: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /root/poco/myPocoTest/libPocoNet.so.71)
./a.out: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /root/poco/myPocoTest/libPocoNet.so.71)
查看缺少GLIBCXX_3.4.20
[root@jn myPocoTest]# strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_DEBUG_MESSAGE_LENGTH
原因是升级gcc时动态库没有替换旧的动态库文件
查找编译过的gcc库文件位置:
find / -name "libstdc++.so*"
[root@jn myPocoTest]# find / -name "libstdc++.so*"
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
/usr/local/gcc/lib64/libstdc++.so.6.0.20-gdb.py
/usr/local/gcc/lib64/libstdc++.so.6
/usr/local/gcc/lib64/libstdc++.so.6.0.20
/usr/local/gcc/lib64/libstdc++.so
/usr/local/gpsserv/libstdc++.so.6
/usr/local/gpsserv_2/libstdc++.so.6
/root/.debug/usr/lib64/libstdc++.so.6.0.19
/root/lib/libstdc++.so.6
/root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.20
/root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/root/GCC_4.9.2/gcc-4.9.2/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/root/GCC_4.9.2/gcc-4.9.2/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.20
/root/GCC_4.9.2/gcc-4.9.2/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/root/GCC_4.9.2/gcc-4.9.2/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/root/GCC_4.9.2/gcc-4.9.2/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.20
/root/GCC_4.9.2/gcc-4.9.2/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/root/downloads/datahub_C++_sdk_14.0/lib/libstdc++.so.6
/root/downloads/datahub_cpp_sdk_release_64/allfiles/libstdc++.so.6
/root/downloads/datahub_cpp_sdk_release_64/lib/libstdc++.so.6
/var/lib/docker/overlay2/e05124a5a8cdb68cbf1b5394067bf87ba508301ed91d84c1d7cff3316c3a1e21/diff/tmp/tmp.QX7dilbd7Z/stage1-x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/var/lib/docker/overlay2/e05124a5a8cdb68cbf1b5394067bf87ba508301ed91d84c1d7cff3316c3a1e21/diff/tmp/tmp.QX7dilbd7Z/stage1-x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.28
/var/lib/docker/overlay2/e05124a5a8cdb68cbf1b5394067bf87ba508301ed91d84c1d7cff3316c3a1e21/diff/tmp/tmp.QX7dilbd7Z/stage1-x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/var/lib/docker/overlay2/e05124a5a8cdb68cbf1b5394067bf87ba508301ed91d84c1d7cff3316c3a1e21/diff/tmp/tmp.QX7dilbd7Z/prev-x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
/var/lib/docker/overlay2/e05124a5a8cdb68cbf1b5394067bf87ba508301ed91d84c1d7cff3316c3a1e21/diff/tmp/tmp.QX7dilbd7Z/prev-x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.28
/var/lib/docker/overlay2/e05124a5a8cdb68cbf1b5394067bf87ba508301ed91d84c1d7cff3316c3a1e21/diff/tmp/tmp.QX7dilbd7Z/prev-x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
/var/lib/docker/overlay2/70bba9113499bdc3ce4d083aee2c0c69e385cd1bb8596cd5b5658868e5aca6a7/diff/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/var/lib/docker/overlay2/70bba9113499bdc3ce4d083aee2c0c69e385cd1bb8596cd5b5658868e5aca6a7/diff/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25
/var/lib/docker/overlay2/70bba9113499bdc3ce4d083aee2c0c69e385cd1bb8596cd5b5658868e5aca6a7/diff/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25-gdb.py
/var/lib/docker/overlay2/53b08252aeea199eb2780e77b8c6cd8924eaf10120ab43993bdbe2380e3fc28f/diff/usr/lib/x86_64-linux-gnu/libstdc++.so.6
发现存在相同,检查字符发现确实多了很多高版本的
[root@jn myPocoTest]# strings /root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_DEBUG_MESSAGE_LENGTH
_ZNKSt14basic_ifstreamIcSt11char_traitsIcEE7is_openEv@GLIBCXX_3.4
_ZNSt13basic_istreamIwSt11char_traitsIwEE6ignoreEv@@GLIBCXX_3.4.5
_ZNKSbIwSt11char_traitsIwESaIwEE11_M_disjunctEPKw@GLIBCXX_3.4
_ZNKSt14basic_ifstreamIwSt11char_traitsIwEE7is_openEv@@GLIBCXX_3.4.5
GLIBCXX_3.4.9
_ZSt10adopt_lock@@GLIBCXX_3.4.11
GLIBCXX_3.4.10
GLIBCXX_3.4.16
GLIBCXX_3.4.1
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv@GLIBCXX_3.4
_ZNSs7_M_copyEPcPKcm@GLIBCXX_3.4
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv@@GLIBCXX_3.4.5
_ZNSs7_M_moveEPcPKcm@@GLIBCXX_3.4.5
_ZNKSt13basic_fstreamIwSt11char_traitsIwEE7is_openEv@GLIBCXX_3.4
_ZNKSt13basic_fstreamIcSt11char_traitsIcEE7is_openEv@GLIBCXX_3.4
_ZNSbIwSt11char_traitsIwESaIwEE4_Rep26_M_set_length_and_sharableEm@@GLIBCXX_3.4.5
_ZNSs4_Rep26_M_set_length_and_sharableEm@GLIBCXX_3.4
_ZSt10defer_lock@@GLIBCXX_3.4.11
_ZN10__gnu_norm15_List_node_base4swapERS0_S1_@@GLIBCXX_3.4
_ZNSs9_M_assignEPcmc@@GLIBCXX_3.4.5
将该文件的软连接文件和源文件一起复制到错误提示的 /lib64 目录下即可
[root@jn myPocoTest]# ll /root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
lrwxrwxrwx 1 root root 19 Mar 1 14:34 /root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 -> libstdc++.so.6.0.20
[root@jn myPocoTest]# cp /root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6 /lib64/
cp: overwrite ‘/lib64/libstdc++.so.6’? y
[root@jn myPocoTest]# ls
a.out libPocoCrypto.so.71 libPocoData.so libPocoDataSQLite.so.71 libPocoFoundation.so libPocoJSON.so.71 libPocoMongoDB.so libPocoNet.so.71 libPocoRedis.so libPocoUtil.so.71 libPocoZip.so version.cpp
download.cpp libPocoDataMySQL.so libPocoData.so.71 libPocoEncodings.so libPocoFoundation.so.71 libPocoJWT.so libPocoMongoDB.so.71 libPocoNetSSL.so libPocoRedis.so.71 libPocoXML.so libPocoZip.so.71
libPocoCrypto.so libPocoDataMySQL.so.71 libPocoDataSQLite.so libPocoEncodings.so.71 libPocoJSON.so libPocoJWT.so.71 libPocoNet.so libPocoNetSSL.so.71 libPocoUtil.so libPocoXML.so.71 Makefile
[root@jn myPocoTest]# cp /root/GCC_4.9.2/gcc-4.9.2/stage1-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.20 /lib64/
[root@jn myPocoTest]# ./a.out
usage: a
Download to standard output.
Works with http, ftp and file URIs.
运行成功:
[root@jn myPocoTest]# ./a.out http://121.196.173.100:9682/hello.html
hello,from http server
[root@jn myPocoTest]#