C++ 未找到版本“GLIBCXX_3.4.22”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43070900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 15:32:43  来源:igfitidea点击:

Version `GLIBCXX_3.4.22' not found

c++ubuntu-16.04libstdc++

提问by dk13

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 foundpops 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?

我在 VM Ubuntu 16.04 上构建了一个 C++ 应用程序,在该 VM 上安装了 g++ 编译器 6.2.0 以支持 C++14 功能。当我尝试在默认为 g++ 5.4.0 的新干净 VM 16.04 上运行它时,会弹出错误 /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found
我注意到在 VM 上安装了更新的编译器库 libstdc++.so.6.0.22。在干净的 VM 上,我想避免更新编译器,因此我尝试仅安装最新的 libstdc++6 包。但是安装的库是 libstdc++.so.6.0.21 ,所以问题仍然存在。如何专门安装 libstdc++.so.6.0.22 版本?

采纳答案by Gert Wollny

You could try to use pinningto 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.

或者,您可以简单地使用 g++ 5.4 编译您的程序,因为根据此页面,该编译器已经支持所有 c++14,唯一的区别是 g++-6 默认为-std=c++14,而使用 g++- 5 您必须明确设置语言标准。

回答by Krishan Kumar Mourya

You need to upgrade libstdc++6 to latest version like this

您需要像这样将 libstdc++6 升级到最新版本

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:

之后,您可以检查是否获得了 GLIBCXX 所需的版本,如下所示:

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX