Передача `-std = c ++ 11` в CMakeLists?

Я только что установил Qt Creator и использую синтаксис 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».

Мой 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})

РЕДАКТИРОВАТЬ: крошечный тестовый пример, показывающий проблему https://gist.github.com/anonymous/8171073

14

Решение

main.cpp

#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);
}

CMakeLists.txt

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})
33

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector