When executing the program , Tips : ./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not
found (required by ./a.out)

I'm compiling GCC Source code upgrade GCC This problem occurred after the version , This is because GCC After upgrading, the standard library is still caused by the old one , The solution is as follows :

Method 1 :

    In compiling GCC In the , lookup libstdc++ Related libraries , And copy to /usr/lib Under the table of contents , And re-establish the soft connection .

1. Switch to root user su -

2. Enter compilation GCC Table of contents ,   I was in /opt Under compiled , cd /opt/build-gcc

3. lookup libstdc library    find ./ -name libstdc++.so*    

[root@localhost build-gcc]# find ./ -name libstdc++.so*  
./stage1-i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
./stage1-i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.21
./stage1-i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
./i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
./i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.21
./i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
./prev-i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6
./prev-i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.21
./prev-i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so
[root@localhost build-gcc]# 

4.  cp ./i686-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.21
 /usr/lib   64 Bit system may be in /usr/lib64 lower

5. cd  /usr/lib

6. ls -l |grep libstdc++       You can see the following

lrwxrwxrwx   1 root root       19 Mar  2 19:07 libstdc++.so.6 ->
libstdc++.so.6.0.8
-rwxr-xr-x   1 root root  9254976 Mar  2 19:05 libstdc++.so.6.0.21
-rwxr-xr-x   1 root root   936908 Jul 10  2007 libstdc++.so.6.0.8

7. rm -f libstdc++.so.6 8. ln -s libstdc++.so.6.0.21 libstdc++.so.6.0.8
Everything should be back to normal

Method 2 : The method of statically linking standard library at compile time , Add at compile time  -static-libstdc++ option

Technology
©2019-2020 Toolsou All rights reserved,
use easyPOI Import Excel data Vue Transfer parameters and receiving of page Jump Digital rolling lottery program The difference between memory overflow and memory leak , Causes and Solutions vue monitor Treeselect Change of options Image format conversion TypeScript- Polymorphism JavaScript Medium Call and Applyk8s Entry to give up --k8s Key concepts How to build data security system ?