Version `GLIBCXX_3.4.22' not found
Asked Answered
B

2

26

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?

Blinker answered 28/3, 2017 at 13:26 Comment(1)
Link everything besides libc statically.Bold
T
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.

Tornado answered 28/3, 2017 at 17:45 Comment(1)
Well, that's surely not the only difference though between GCC 5 and GCC 6 in terms of C++14.Frond
C
60

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
Crackbrain answered 6/10, 2017 at 20:52 Comment(1)
For others: if the command add-apt-repository fails you like it failed me, follow the instructions here (replace precise with your ubuntu version): askubuntu.com/a/193520/376175Waterway
T
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.

Tornado answered 28/3, 2017 at 17:45 Comment(1)
Well, that's surely not the only difference though between GCC 5 and GCC 6 in terms of C++14.Frond

© 2022 - 2024 — McMap. All rights reserved.