Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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).

like image 812
Natalia Zoń Avatar asked Oct 16 '13 08:10

Natalia Zoń


2 Answers

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
like image 82
TheDarkKnight Avatar answered Oct 27 '22 05:10

TheDarkKnight


You can change CXX flags :

QMAKE_CXXFLAGS += -std=c++11

I usually set it as :

QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic
like image 23
BЈовић Avatar answered Oct 27 '22 05:10

BЈовић