C++ Qt - How to add "-std=c++11" to the makefile which is generated by qmake?

Natalia Zoń picture Natalia Zoń · Oct 16, 2013 · Viewed 58.8k times · Source

I'm developing a program in Qt. Its makefile is generated automatically from the .pro file. I need to use some code which need the -std=c++11 flag to be set up for g++. Where in .pro should I add this flag? (changing only the Makefile won't work since it gets overwritten by the newly generated one, each time I build the project).

Answer

TheDarkKnight picture TheDarkKnight · Oct 16, 2013

You can add the following to the Qt .pro for C++11: -

CONFIG += c++11

As of Qt 5.4, C++14 can be enabled with

CONFIG += c++14