2

I am trying to build my Qt project with C++11 standard. I added this flag in the build steps, additional argument option, in the Qt Creator :

-std=c++11

But I got this error while building :

Unknown option -std=c++11

g++ version info : g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

Any ideas ?

Amit Tomar
  • 4,800
  • 6
  • 50
  • 83
  • 1
    possible duplicate of [How to enable c++11 in qt creator 2.7.0?](http://stackoverflow.com/questions/16948382/how-to-enable-c11-in-qt-creator-2-7-0) – László Papp May 03 '14 at 02:51

2 Answers2

13

Use the qmake project file, add this line: QMAKE_CXXFLAGS += -std=c++11

LE: also 4.6.3 might not support C++11 (as far as i know 4.7 and higher support -std=c++11) so the option for the 0x features implemented might be: QMAKE_CXXFLAGS += -std=c++0x

Zlatomir
  • 6,964
  • 3
  • 26
  • 32
  • 2
    Agreed.gcc-4.6 does not support -std=c++11 "To enable C++0x support, add the command-line parameter -std=c++0x to your g++ command line. Or, to enable GNU extensions in addition to C++0x extensions, add -std=gnu++0x to your g++ command line. GCC 4.7 and later support -std=c++11 and -std=gnu++11 as well." http://gcc.gnu.org/projects/cxx0x.html – drescherjm Jun 25 '13 at 17:21
  • @drescherjm thanks for the information, i wasn't sure about that. – Zlatomir Jun 25 '13 at 17:30
  • @drescherjm Thanks.. I updated g++ to 4.7 and used the above stated flag, works like a charm. – Amit Tomar Jun 26 '13 at 12:41
10

If you are using Qt5, add CONFIG += c++11 to your .pro file, that works on all systems.

Thomas McGuire
  • 5,308
  • 26
  • 45