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*  
[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 ->
-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

©2019-2020 Toolsou All rights reserved,
C Review of basic language knowledge Go Language learning notes (GUI programming )Java Misunderstanding —— Method overloading is a manifestation of polymorphism ? How to achieve low cost and high stability for cloud native applications ?elementui Shuttle box el-transfer Display list content text too long C/C++ Memory model Element-Ui assembly Message Message prompt , alert Popup C# Making a simplified version of calculator Python In pycharm editor Interface style modification Tiktok refresh progress bar ( Two little balls turn ), The code is simple