无法用"-std=c++11"编译《你好世界》
Can't compile Hello World with "-std=c++11"
我的G 编译器似乎有问题。它无法使用ubuntu上的" -std = c 11"选项编译代码16.04使用G 5.4.0。
所以我写了一个非常简单的Hello World程序:
//Hello.cpp
#include <iostream>
using namespace std;
int main(){
cout<<"Hello World"<<endl;
}
如果我用G 编译:
g hello.cpp
它可以正常工作。
但是,如果我添加" -std = c 11":
g -std = C 11 hello.cpp
g 给我大量的错误消息,超过1000行。
这是其中的一些:
In file included from /usr/include/c++/5/bits/stl_pair.h:59:0,
from /usr/include/c++/5/bits/stl_algobase.h:64,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from Hello.cpp:1:
/usr/include/c++/5/bits/move.h:76:27: error: ‘remove_reference’ in namespace ‘std’ does not name a template type
forward(typename std::remove_reference<_Tp>::type& __t) noexcept
^
/usr/include/c++/5/bits/move.h:76:43: error: expected ‘,’ or ‘...’ before ‘<’ token
forward(typename std::remove_reference<_Tp>::type& __t) noexcept
^
/usr/include/c++/5/bits/move.h: In function ‘constexpr _Tp&& std::forward(int)’:
/usr/include/c++/5/bits/move.h:77:33: error: ‘__t’ was not declared in this scope
{ return static_cast<_Tp&&>(__t); }
^
相同的代码在其他计算机上正常工作。
你有什么想法吗?
上面的错误消息不是第一行,第一行说:
In file included from
/usr/include/c++/5/experimental/type_traits:39:0,
from /usr/include/c++/5/bits/move.h:57,
from /usr/include/c++/5/bits/stl_pair.h:59,
from /usr/include/c++/5/bits/stl_algobase.h:64,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from Hello.cc:1:
/usr/include/c++/5/bits/c++14_warning.h:32:2: error: #error This file requires compiler and library support for the forthcoming ISO C++ 2014 standard.
This support is currently experimental, and must be enabled with the -std=c++1y or -std=gnu++1y compiler options.
,但即使使用" -std = c 1y"或" -std = gnu 1y",g 仍然给我一大堆错误消息。
libstdc 6已安装在我的系统上,这不是我在此PC上使用" -STD = C 11"的第一个CPP程序(以前可以正常工作(。
我不记得我修改了什么,但是我会尝试重新安装工具链。
谢谢!
您对计算机的软件包依赖项做了一些奇怪的事情。
gcc 5需要libstdc 6,但是您有libstdc 5(如路径所示(。
这意味着您的编译器和标准库实施不同步。
重新安装您的工具链。
相关文章:
- 你好世界在 APUE 第 7 章退出,代码为 0
- 包括操作系统你好世界失败
- 无法用"-std=c++11"编译《你好世界》
- 构建 wxWidgets 你好世界
- 你好世界示例,一个在 C 语言中使用 SSL 的猫鼬网络服务器
- v8 你好世界示例链接错误
- 尝试运行SFML你好世界代码,我得到和错误
- 可视化C++工作区和编译器.你好世界测试初学者
- C++你好世界不工作
- AT&T内联C++你好世界错误
- 如何在运行时给出“你好世界”
- 你好世界,只有返回主要
- 你好世界在 GCC 5.3.0 上失败 /bin/ld:无效选项 -- 'p'
- 开发C++你好世界不显示
- mpi你好世界不工作
- Libspotify简单的你好世界
- cpcms你好世界应用程序与MS vc 2013 Express
- C++,无法让它运行你好世界代码
- C++ 你好世界不会编译?似乎是一个链接问题...
- GTKmm 你好世界编译错误