您的位置:首页 > 编程语言 > C语言/C++

关于make提示must be enabled with the -std=c++11 or -std=gnu++11 compiler options

2016-12-02 19:03 1031 查看
在make后,出现错误,提示如下:

/usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^


原因是写的CMakeLists.txt文件没有添加对C++11的支持,所以在工程目录下的CMakeLists.txt中添加以下语句:

SET( CMAKE_CXX_FLAGS "-std=c++11 -O3")


然后编译即可通过。

其中,参数CMAKE_CXX_FLAGS含义是: set compiler for c++ language

而后面的-O3(是字母opq的o,大写的欧)是用来调节编译时的优化程度的,最高为-O3,最低为-O0(即不做优化)

-Ox这个参数只有在CMake -DCMAKE_BUILD_TYPE=Release时有效,因为debug 版的项目生成的可执行文件需要有调试信息并且不需要进行优化,而 release 版的不需要调试信息但需要优化
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cmake compiler linux
相关文章推荐