红联Linux门户
Linux帮助

在ubuntu下使用QT Cmake支持C++11

发布时间:2016-04-20 15:22:38来源:linux网站作者:ZeeCoder

今天在ubuntu下使用QT来进行C++编程,选择了Cmake,当用到initializer_list的时候提示不支持C++11,现提供一下解决方案:


错误提示:
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.


解决方案:
在CmakeLists.txt中添加:set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")


如下列代码所示:

project(lesson)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})


本文永久更新地址:http://www.linuxdiyf.com/linux/19929.html