This error is usually caused by a missing required version of the C++ standard library on your system. GLIBCXX_3.4.2 and GLIBXX_3.4.21 are two specific versions of the C++ standard library. The above error will appear when compiling and running some scripts and other files.
1. Enter the following command in the terminal to check the missing GLIBCXX version:
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
2. Find the location of the compiled gcc library file:
find / -name "libstdc++.so*"
Find a higher version library path in the output. Here I chose the 6.0.28 that comes with gcc.
3. Delete the original soft link and create a new soft link
rm -f /usr/lib64/libstdc++.so /usr/lib64/libstdc++.so.6
cd /usr/lib64
ln -s /usr/local/gcc-10.4.0/lib64/libstdc++.so.6.0.28 libstdc++.so
ln -s /usr/local/gcc-10.4.0/lib64/libstdc++.so.6.0.28 libstdc++.so.6
4. Verify whether the link is successful
ll /usr/lib64/libstdc++*
You will get the following output: