1

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

  • Changing to CONFIG += c++11 didn't worked
  • My compiler on project is /usr/bin/g++ and if I run /usr/bin/g++ --version returns 5.4.0 20160609

Update 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

Community
  • 1
  • 1
Fnr
  • 2,096
  • 7
  • 41
  • 76

2 Answers2

3

As described here http://doc.qt.io/qt-5/qmake-variable-reference.html , you should add CONFIG += c++11 in your .pro file

Fryz
  • 2,119
  • 2
  • 25
  • 45
  • 1
    I already tried this, didn't worked. Maybe I am missing some packages to install? – Fnr Jan 07 '17 at 15:27
  • Are you sure that in your project Kit, the C++ compiler is set to g++ version 5.4.0 ? – Fryz Jan 07 '17 at 15:40
  • Yes, in the project kit manager, the path to the compiler is `/usr/bin/g++`. If I run `/usr/bin/g++ --version` it returns me 5.4 – Fnr Jan 07 '17 at 22:45
1

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

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

Should be

QMAKE_CXXFLAGS += -std=c++11
Tobias
  • 835
  • 1
  • 6
  • 11
  • Looks like your compiler don't support c++11 are you certain it uses /usr/bin/g++?. My setup is qt 5.2.1, qmake 3.0 with g++ 4.8.4. – Tobias Jan 08 '17 at 13:53
  • Yes because NetBeans also uses `/usr/bin/g++` as compiler and a project set to standard c++11 compiles and run normally. – Fnr Jan 08 '17 at 15:40
  • I get the error "***Unknown option -std=c++11" when I run qmake -std=c++11. – Tobias Jan 08 '17 at 16:10