Brian Stinar Brian Stinar - 1 year ago 58
Linux Question

CXXFLAGS modification From My .pro File

Possible Duplicate:

Configuring the GCC compiler switches in Qt, QtCreator, and QMake

I would like to use
instead of
2 in my makefile (
) for my Linux build, but my understanding of how these makesfiles are generated based on the .pro file is somewhat lacking. This is because the version of Qt combined with the version of G++ I am using has instabilities when -O2 is present.

Presently, I am running a replacement script, after I run qmake, which does this:

sed -i 's/\-O2/\-O1/g' AllProjects/Makefile.Release

This is a ghetto solution. A much better solution would be to modify the .pro file somehow to pass along these directives. I am not sure how CFLAGS and CXXFLAGS are being generated though, and I figured I would ask wonderful StackOverflow.

I have tried passing a


which did not work.

Answer Source

You were very close. What you want is:


If you would like to apply flags to just the release build, then you can use this:


You also probably want to change your condition to be a little more flexible. In summary, something like this:

*-g++* {

More in the documentation here: