I need to generate a 32 bits version of my application however I am compiling on a 64 bits OS. I'm looking for a way to make QMake to generate both 32 and 64 bits versions of my application. If this is not possible I would like to know how to switch to 32 bits. I would also like to avoid having to mess with the generated makefile.
Asked
Active
Viewed 1.3k times
2 Answers
8
Use a construction something like:
CONFIG += 32bit
CONFIG(32bit) {
TARGET = 32bit_binary
QMAKE_CXXFLAGS += -m32
LIBS += -L<path to 32bit libraries>
}
CONFIG(64bit) {
TARGET = 64bit_binary
}
in your .pro file. Then you only need to change one line to recompile for the other architecture.

PiedPiper
- 5,735
- 1
- 30
- 40
-
You didn't mention which compiler you are using: you will need to change the flags in my example to the right ones for your compiler. – PiedPiper Dec 10 '10 at 00:31
-
I'm using GCC so I believe '-m32' is correct but for some reason the qmake generates the makefile with '-m64' anyway – Raphael Dec 13 '10 at 06:08
-
Sorry the variale should be QMAKE_CXXFLAGS and not QMAKE_CFLAGS_RELEASE. I've edited my answer – PiedPiper Dec 13 '10 at 23:33
-
Thank you very much for this. This is going straight to my cheat list. – Raphael Dec 16 '10 at 11:09
2
Make use of win32:
in front of each command you would like be run for win32 architecture only. Or can use a scope as
win32 {
SOURCES += paintwidget_win.cpp
}
Also, you may refer to the architecture win32 or x64 with the ($Platform) MSDN macro for Visual Studio.

kiriloff
- 25,609
- 37
- 148
- 229