Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans "-O3" optimization for Qt projects

Tags:

c++

qt

netbeans

I'm coding Qt/C++ in Netbeans 7.0 and i want enable -O3 compiler switch for my project. The default optimization level of building a project is -O2 in Netbeans.

I added -O3 in this way:

Properties > Build > Qt > Expert > Custom Definitions > Add QMAKE_CXXFLAGS += -O3.

but when rebuilding the project i see this for each .cpp file:

g++.exe -c -O3 -O2 -frtti -fexceptions -mthreads -Wall ...... test.cpp

and i think the first -O3 is dropped by second -O2, and the optimization level -O2

how can i configure my project through Properties > Build > .... for -O3? or, how can i remove -O2?

like image 747
masoud Avatar asked Oct 17 '11 17:10

masoud


2 Answers

I assume you need -O3 for release build only, right?

Then setting QMAKE_CXXFLAGS_RELEASE += -O3 puts -O3 ater -O2, at least in my command line build in Debian and MacOS X.

That would make sense, since -O2 is provided by QMAKE_CXXFLAGS_RELEASE in platform-specific mkspecs, so appending anything should work like this.

like image 72
ayoy Avatar answered Sep 27 '22 19:09

ayoy


Add two entries in the Custom Definitions box: one with QMAKE_CXXFLAGS -= -O2 and another with QMAKE_CXXFLAGS += -O3. This will remove the -O2 flag and add the -O3 flag.

like image 26
messenjah Avatar answered Sep 27 '22 18:09

messenjah