Qmake不使用stdc++11编译标志

5
当我尝试编译我的项目时,出现了以下错误:
g++ -c -pipe -std=c++11 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -std=gnu++98 -Wno-deprecated -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I+= -I../includes -I. -I. -o ThreadPool.o ../sources/ThreadPool.cpp
In file included from /usr/include/c++/5.3.1/thread:35:0,
                 from ../includes/ThreadPool.hpp:4,
                 from ../sources/ThreadPool.cpp:1:
/usr/include/c++/5.3.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \

我不明白为什么在我的Makefile中使用了标识-std=c++11后还是出现问题。

#-------------------------------------------------
#
# Project created by QtCreator 2016-04-11T18:51:06
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = plazza_gui


SOURCES +=  main.cpp\
            ../sources/Window.cpp \
            ../sources/ThreadPool.cpp \
            ../sources/ProcessManager.cpp \
            ../sources/Process.cpp \
            ../sources/NamedPipe.cpp \
            ../sources/Xor.cpp \
            ../sources/AEncryptionMethod.cpp \
            ../sources/Cesar.cpp \
            ../sources/ProcessData.cpp \
            ../sources/Parser.cpp

HEADERS  += ../includes/Window.hpp

INCLUDEPATH +=  += ../includes/


FORMS    += forms/mainwindow.ui

QMAKE_CXXFLAGS += -std=c++11

LIBS += \
  -lboost_regex \

DISTFILES += \
    ressources/pizzera.jpg \
    ressources/pizzeria.png \
    ressources/icon.png

RESOURCES += \
    ressources/ico.qrc

这个 Makefile 在我朋友的电脑上能够正常运行,但是当我克隆它后无法编译。


1
请检查您的设置。您的命令行包含一个 -std=gnu++98,这很可能会覆盖您的 -std=c++11 - Simon Kraemer
我该找谁来解决这个问题?我的 Makefile 中没有使用 -std=gnu++98 标志。 - CE_
http://pastebin.com/EJZnMtaB - CE_
抱歉,我贴错了链接,这是正确的链接 http://pastebin.com/kZvNiMXj,其中包含 CXXFLAGS = -pipe -std=c++11 - CE_
你尝试过清理项目吗?如果没有,请尝试使用 make distclean,然后再次运行 qmake - exilit
显示剩余5条评论
1个回答

2
这意味着你的编译器不支持以那种方式使用c++11。如果你确定你的编译器不是那么老,可以尝试这个:
CONFIG += c++11

gcc版本5.3.1 20160406(Red Hat 5.3.1-6)(GCC),您的解决方案似乎无效。 - CE_
它在我的配置上运行正常:g++ -c -pipe -Wall -Wextra -Wno-deprecated-declarations -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_CORE_LIB -I../../../KinematicUI -I. -Iinc -I../../../criifLib/include -I/opt/Qt/5.6/gcc_64/include -I/opt/Qt/5.6/gcc_64/include/QtOpenGL -I/opt/Qt/5.6/gcc_64/include/QtWidgets -I/opt/Qt/5.6/gcc_64/include/QtGui -I/opt/Qt/5.6/gcc_64/include/QtXml -I/opt/Qt/5.6/gcc_64/include/QtCore -I. -I. -I/opt/Qt/5.6/gcc_64/mkspecs/linux-g++ -o main.o ../../main.cpp - Boiethios
@Morovaille 这就是问题所在,它在我朋友的电脑上可以运行,但在我的电脑上无法编译。 - CE_
3
在对 .pro 文件进行更改后,您需要运行 qmake(顶级菜单选项“构建”=>“运行qmake”),否则它将无法正常工作。 - Elijan9
@CE_ 在开始之前确保你已经清理了项目。 - Victor Polevoy
1
@CE_你不必运行qmake来更改.pro文件,qmake的作用是通过您的.pro文件生成Makefile,这个Makefile将被make工具用于编译您的项目。.pro文件只是一种描述make文件的简单方式而已。 - Victor Polevoy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接