I am trying to pass optimization flags to gcc using the qmake .pro file:
我正在尝试使用qmake .pro文件将优化标志传递给gcc:
hello.pro:
hello.pro:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp
QMAKE_CXXFLAGS += -O3 \
main.cpp:
main.cpp:
#include <iostream>
int main()
{
std::cout << "Hi!" << std::endl;
return 0;
}
compilation output:
编译输出:
15:14:34: Running steps for project TestGrounds...
15:14:34: Starting:
"/usr/bin/make" clean rm -f main.o
rm -f *~ core *.core
15:14:34: The process "/usr/bin/make" exited normally.
15:14:34: Configuration unchanged, skipping qmake step.
15:14:34: Starting: "/usr/bin/make"
g++ -c -pipe -O3 -O2 -Wall -W -fPIE -I/opt/Qt5.2.0/5.2.0/gcc/mkspecs/linux-g++ -I../../Projects/TestGrounds -I. -o main.o ../../Projects/TestGrounds/main.cpp
g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.2.0/5.2.0/gcc -o TestGrounds main.o
15:14:35: The process "/usr/bin/make" exited normally.
15:14:35: Elapsed time: 00:01.15:14:项目测试场地的运行步骤……15:14:34:开始:“/usr/bin/make”clean rm -f main。o rm -f *~ core *。进程"/usr/bin/make"正常退出。15:14:34:配置不变,跳过qmake步骤。15:14:34:开始:“/ usr / bin /做出“g++ - c管o3 - 02 - wall - w -fPIE - i / opt / Qt5.2.0/5.2.0 / gcc / mkspecs / linux-g + +我. . / . ./项目/ TestGrounds -我。- o主要。o . . / . . /项目/ TestGrounds /主要。cpp g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.2.0/5.2.0/gcc -o测试场主。o 15:14:35:流程“/usr/bin/make”正常退出。15:14:35:运行时间:00:01。
But why are the -O1 and -O2 optimization flags passed too?
但是为什么-O1和-O2优化标志也被传递了呢?
I tried to clean the project and rebuild it and the result is the same.
我试图清理项目并重新构建它,结果是一样的。
2 个解决方案
#1
11
Try this
试试这个
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE *= -O3
#2
2
There an easier option now, add this in the project settings:
现在有一个更简单的选项,添加到项目设置中:
CONFIG += optimize_full
Or in your .pro:
或者在你的.pro:
CONFIG(release, debug|release) {
CONFIG += optimize_full
}
It will replace the -O2 with -O3. (seems to be there since 2014)
它会用-O3取代-O2。(好像2014年就有了)
#1
11
Try this
试试这个
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE *= -O3
#2
2
There an easier option now, add this in the project settings:
现在有一个更简单的选项,添加到项目设置中:
CONFIG += optimize_full
Or in your .pro:
或者在你的.pro:
CONFIG(release, debug|release) {
CONFIG += optimize_full
}
It will replace the -O2 with -O3. (seems to be there since 2014)
它会用-O3取代-O2。(好像2014年就有了)