Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 通过`-std=c++;11 `给CMakeLists?_C++_Qt_C++11_Cmake_Compiler Flags - Fatal编程技术网

C++ 通过`-std=c++;11 `给CMakeLists?

C++ 通过`-std=c++;11 `给CMakeLists?,c++,qt,c++11,cmake,compiler-flags,C++,Qt,C++11,Cmake,Compiler Flags,我刚刚安装了QtCreator,正在使用C++11语法 不幸的是,当我尝试构建我的项目时,我得到了: /usr/include/c++/4.8/bits/c++0x_warning.h:32: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, a

我刚刚安装了QtCreator,正在使用C++11语法

不幸的是,当我尝试构建我的项目时,我得到了:

/usr/include/c++/4.8/bits/c++0x_warning.h:32: 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 \
       ^
然后是一堆错误,比如“
tuple
不是
std
的成员”

My CMakeLists.txt包含:

project(routing_tests)
set(QMAKE_CXXFLAGS "-std=c++11")
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
编辑:显示问题的小测试用例

main.cpp
显示cmake输出,请同时显示完整的CMakeLists.txt文件。请稍等QMake或cmake?@drescherjm:正是我回答的重点。如果cmake不设置(cmake_CXXFLAGS“-std=c++11”)啊。我的屏幕直到现在才反映出你的答案..啊,所以是CMAKE而不是GMAKE。@AT:你的意思是
QMAKE
,不是
GMAKE
。你是今天第二个打字的人。:)@AT:您需要重新运行cmake。请尝试添加定义(“-std=c++11”)@drescherjm:我想AT只是想编辑我的答案,但不幸被拒绝了。正如要点所指出的那样,没有问题,现在问题已经解决了。
#include <iostream>
#include <tuple>

int main() {
    auto foo = std::make_tuple("bar", "foo", "can");
    std::cout << std::get<0>(foo) << std::get<1>(foo) << std::get<2>(foo);
} 
project(tuple_tests)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# C++14: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})