[英]Netbeans “-O3” optimization for Qt projects
I'm coding Qt/C++ in Netbeans 7.0 and i want enable -O3
compiler switch for my project. 我正在Netbeans 7.0中编码Qt / C ++,我想为我的项目启用-O3
编译器开关。 The default optimization level of building a project is -O2
in Netbeans. 在Netbeans中,构建项目的默认优化级别是-O2
。
I added -O3
in this way: 我以这种方式添加-O3
:
Properties > Build > Qt > Expert > Custom Definitions > Add QMAKE_CXXFLAGS += -O3
. 属性>构建> Qt>专家>自定义定义>添加QMAKE_CXXFLAGS += -O3
。
but when rebuilding the project i see this for each .cpp file: 但是当重建项目时,我看到每个.cpp文件的内容:
g++.exe -c -O3 -O2 -frtti -fexceptions -mthreads -Wall ...... test.cpp 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
我认为第一个-O3
会被第二个-O2
删除,而优化级别-O2
how can i configure my project through Properties > Build > ....
for -O3
? 如何通过-O3
Properties > Build > ....
配置我的项目? or, how can i remove -O2
? 或者,如何去除-O2
?
Add two entries in the Custom Definitions box: one with QMAKE_CXXFLAGS -= -O2
and another with QMAKE_CXXFLAGS += -O3
. 在“自定义定义”框中添加两个条目:一个带有QMAKE_CXXFLAGS -= -O2
,另一个带有QMAKE_CXXFLAGS += -O3
。 This will remove the -O2
flag and add the -O3
flag. 这将删除-O2
标志并添加-O3
标志。
I assume you need -O3
for release build only, right? 我认为您只需要-O3
进行发行,对吗?
Then setting QMAKE_CXXFLAGS_RELEASE += -O3
puts -O3
ater -O2
, at least in my command line build in Debian and MacOS X. 然后将QMAKE_CXXFLAGS_RELEASE += -O3
设置为-O3
ater -O2
,至少在我在Debian和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. 这是有道理的,因为-O2
是QMAKE_CXXFLAGS_RELEASE
在特定于平台的mkspec中提供的,因此附加任何内容都应像这样进行。
使Netbeans使用-O3的方法是进入“项目”属性>“构建”>“ C ++编译器”,然后将“开发模式”设置为“ Performance Release”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.