[SOLVED] Optimized compiling with Qt
-
wrote on 20 Oct 2011, 20:43 last edited by
Hello
How do I apply third level optimization (-O3) for g++ compiler in a Qt project? Setting CXXFLAGS didn't help.
-
wrote on 20 Oct 2011, 21:09 last edited by
You can try
@
remove possible other optimization flags
QMAKE_CFLAGS_RELEASE -= -O
QMAKE_CFLAGS_RELEASE -= -O1
QMAKE_CFLAGS_RELEASE -= -O2add the desired -O3 if not present
QMAKE_CFLAGS_RELEASE *= -O3
@ -
wrote on 20 Oct 2011, 21:20 last edited by
[quote author="Volker" date="1319144953"]You can try
@
remove possible other optimization flags
QMAKE_CFLAGS_RELEASE -= -O
QMAKE_CFLAGS_RELEASE -= -O1
QMAKE_CFLAGS_RELEASE -= -O2add the desired -O3 if not present
QMAKE_CFLAGS_RELEASE *= -O3
@[/quote]
Thank you. but didn't worked for C++. I also do this:
@
QMAKE_CXXFLAGS_RELEASE -= -O
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2QMAKE_CXXFLAGS_RELEASE *= -O3
@Is this correct?
Now programs runs a little faster than previous. (should I also re-compile OpenCV and Qt?)
-
wrote on 20 Oct 2011, 21:30 last edited by
Yes, that's the variable for C++.
Qt itself, and OpenCV are not affected by the change in your project settings, that's right. I'm not sure if you will gain that much speed by switching to -O3. The trolls usually go for sane defaults :) But you will only see if you try.
In case you rebuild Qt, I recommend changing that variable setting in the make spec you use. It's in /path/to/qt/sources/mkspecs
-
wrote on 26 Oct 2011, 07:11 last edited by
I recompiled Qt and OpenCV with -O3 flags (takes 9 hours) and then recompile my program with -O3 flag too.
I can't believe the results! There was only 8 frames per second with normal configuration.... Now it's 38 frames per second :)
This is my qmake.conf:
@qmake configuration for linux-g++
Written for GNU/Linux platforms that have both lib and lib64 directories,
like the AMD Opteron.
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
QMAKE_CFLAGS -= -O2
QMAKE_CFLAGS -= -O1
QMAKE_CXXFLAGS -= -O2
QMAKE_CXXFLAGS -= -O1
QMAKE_CFLAGS = -m64 -O3
QMAKE_LFLAGS = -m64 -O3
QMAKE_CXXFLAGS = -m64 -O3include(../common/g++.conf)
include(../common/linux.conf)QMAKE_LIBDIR_X11 = /usr/X11R6/lib64
QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib64load(qt_config)
@God bless gcc ;)
1/5