【发布时间】:2013-10-31 15:36:49
【问题描述】:
当我使用 VS 2010 在 Qt Creator 2.8 / Qt5.1 下编译项目时,一切都很好。如果我对 MinGW 执行相同操作,则会收到以下错误。
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.
我知道我需要启用 C+11,但我的 .pro 文件中有 CONFIG += console c++11。这不是需要的吗? 我做错了什么?
当我查看品牌时,我看到了:
CXXFLAGS = -pipe -fno-keep-inline-dllexport -g -std=c++0x
令人困惑,正如我在 pro 文件中所说的 c++11。
- 已删除所有内容,运行
qmake等,从头开始,没有结果 - 如前所述,使用 VS2010 可以正常工作
- 从这里使用带有 gcc 4.8.0 的 MinGW。 http://qt-project.org/downloads
- 如果这很重要,Win7 32
已检查:
- 无 ANSI:c++11 #include <thread> gives compile error
- std=c+11 MinGW:C++11 functionality with MinGW
找到解决方案,但只能接受一段时间:https://stackoverflow.com/a/19530028/356726
【问题讨论】:
-
是一样的,除了
-std=c++0x也适用于旧版本的编译器。 -
谢谢。但是为什么当我使用 #include
时出现“必须使用 -std=c++11 启用”错误 -
这确实很奇怪。
-
您确定 gcc 4.8.0 正在被拾取(可能正在找到您机器上的其他发行版)。正如@R.MartinhoFernandes 所说,gcc 应该同样对待
-std=c++0x和-std=c++11。您可以尝试将-v添加到CXXFLAGS以获取有关正在使用的编译器和包含目录的详细信息。
标签: c++ c++11 mingw qt-creator qt5.1