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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With