Fnr
Fnr

Reputation: 2274

how do I add -std=c++11 to the compiler options in my Qt Creator?

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

Update 2

Upvotes: 1

Views: 4133

Answers (2)

Tobias
Tobias

Reputation: 845

Just remove the apostrophes around -std=c++11.

QMAKE_CXXFLAGS += '-std=c++11'

Should be

QMAKE_CXXFLAGS += -std=c++11

Upvotes: 1

kzsnyk
kzsnyk

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

Related Questions