Reputation: 2274
Note: same as this question but for other IDE
I'm trying to compile my Qt Project in Qt Creator IDE but when I click to build, it shows:
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.
When I go to Project -> Build and Run -> Build steps -> Additional arguments and add -std=c++11
and compile it again, I got this on the Compile output:
11:45:37: Running steps for project Youtube-dl-gui...
11:45:37: Starting: "/usr/lib/x86_64-linux-gnu/qt5/bin/qmake" /home/fabio/criação/Youtube-dl-gui/Youtube-dl-gui.pro -r -spec linux-g++-64 CONFIG+=debug -std=c++11
Usage: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake [mode] [options] [files]
...
[here it shows more options of the usage]
...
***Unknown option -std=c++11
11:45:37: The process "/usr/lib/x86_64-linux-gnu/qt5/bin/qmake" exited with code 1.
Error while building/deploying project Youtube-dl-gui (kit: Desktop) When executing step "qmake" 11:45:37: Elapsed time: 00:00.
In my MakeFile config file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Youtube-dl-gui
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
QMAKE_CXXFLAGS += '-std=c++11'
I already tried what was proposed in these threads:
Adding -std=c++11 to compiler options in Anjuta 3.4.3
Qmake doesn't use stdc++11 compilation flag
Update
CONFIG += c++11
didn't worked/usr/bin/g++
and if I run /usr/bin/g++ --version
returns 5.4.0 20160609Update 2
I think my gcc have support to c++11 since in NetBeans I can build and run programs in c++11 standard using the same /usr/bin/g++
binary.
As the compile output shows, the command being run is "/usr/lib/x86_64-linux-gnu/qt5/bin/qmake" /home/fabio/criação/Youtube-dl-gui/Youtube-dl-gui.pro -r -spec linux-g++-64 CONFIG+=debug -std=c++11
and it seems that it is my qmake version 3.0
that doesn't have support for c++11, I guess
Upvotes: 1
Views: 4133
Reputation: 845
Just remove the apostrophes around -std=c++11.
QMAKE_CXXFLAGS += '-std=c++11'
Should be
QMAKE_CXXFLAGS += -std=c++11
Upvotes: 1
Reputation: 2211
As described here http://doc.qt.io/qt-5/qmake-variable-reference.html , you should add CONFIG += c++11
in your .pro file
Upvotes: 3