I have built a C++ app on a VM Ubuntu 16.04 on which I have installed g++ compiler 6.2.0 in order to support C++14 features. When I tried to run it on new clean VM 16.04 which has default the g++ 5.4.0 the error /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found pops up.
I've noticed that on the VM with the updated compiler library libstdc++.so.6.0.22 has been installed. On the clean VM I'd like to avoid to update the compiler so I tried to install only the latest libstdc++6 package. However the library that was installed was libstdc++.so.6.0.21 and so the problem persisted. How can I install specifically the libstdc++.so.6.0.22 version?
Asked
Active
Viewed 5.2k times
25

dk13
- 1,461
- 4
- 20
- 47
-
1Link everything besides libc statically. – Matteo Italia Mar 28 '17 at 17:51
2 Answers
58
You need to upgrade libstdc++6 to latest version like this
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6
After that you can check if you get GLIBCXX desired version like this:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

Krishan Kumar Mourya
- 2,207
- 3
- 26
- 31
-
1For others: if the command `add-apt-repository` fails you like it failed me, follow the instructions here (replace `precise` with your ubuntu version): https://askubuntu.com/a/193520/376175 – John Walthour Jul 31 '18 at 18:55
1
You could try to use pinning to make sure only the packages you want are updated to a newer version.
Alternatively, you could simply compile your program with g++ 5.4, because according to this page, this compiler already supports all c++14, the only difference is that g++-6 defaults to -std=c++14, whereas with g++-5 you have to set the language standard explicitly.

Gert Wollny
- 529
- 2
- 8
-
1Well, that's surely not the only difference though between GCC 5 and GCC 6 in terms of C++14. – rubenvb Aug 22 '19 at 09:38