- All (478)
- jom (0)
- Qt Linguist (7)
- Qt Eclipse Integration (9)
- Qt Designer (7)
- Qt Creator (4)
- Qt build system: qmake (31)
- Qt build system: configure (3)
- Qt Assistant (5)
- Printing (4)
- Porting from Qt 3 to Qt 4 (1)
- Plugins (7)
- Qt Visual Studio AddIn (2)
- Qt/MFC Migration (2)
- QtScript (3)
- MDI (2)
- XML (1)
- Widgets (22)
- WebKit (5)
- Tools and Containers (2)
- Threads (2)
- Text Handling (10)
- SQL (6)
- QtTest (1)
- QtService (1)
- Platform: Windows (49)
- Platform: Unix (16)
- Platform: Mac OS X (18)
- Image Formats (2)
- I/O (2)
- Graphicsview (8)
- Font handling (9)
- Event System (18)
- Drag and Drop (4)
- Dialogs (6)
- Desktop integration (3)
- ActiveQt (3)
- Itemviews (60)
- Layout (4)
- Qt Quick (10)
- Qt SDK (1)
- Licensing (2)
- Platform: Embedded Linux (38)
- Painting (32)
- OpenGL (4)
- Object Model (6)
- Network (5)
- Multimedia (3)
- Miscellanous (23)
- Main Window (19)
- Look and Feel (23)
- Development (0)
- Getting Involved (0)
- Routines (0)
How can I detect in the .pro file if I am compiling for a 32 bit or a 64 bit platform?
You can use QMAKE_TARGET.arch to decide the platform you are building for. You can do it as follows:
- win32-msvc*:contains(QMAKE_TARGET.arch, x86_64):{
- message( "Building for 64 bit")
- }

4 comments
June 14, 2011
Ant Farmer
This seems to be available only on Windows, not on Linux.
Would it not be useful on Linux as well?
June 15, 2011
Lab Rat
Hi,
This is currently a windows/msvc only solution, that is true.
The reason for that is, that on windows you usually build from a visual studio command prompt which allows you to easily figure out the target platform by checking the environment.
On Linux there is no need for a specific build environment and therefor we cannot rely on specific environment variables. The only way to figure out which compiler will be used would be to fire up the compiler itself and “ask” for the target platform. Such a solution is currently too cumbersome and expensive for being used in the .pro parser.
What is the use case for this? – Am i missing something?
June 16, 2011
Ant Farmer
To be honest I’m not sure there is a use case… :)
I just tried to use it on Linux, to differentiate between 32 and 64 bit builds, and was a bit surprised when it didn’t work. But I’m not sure we will ever do 32/64-bit cross compilation on Linux, so using QMAKE_HOST.arch will work just as well. Or, we could (and probably should) use the mkspecs (linux-g++-32 and linux-g++-64) to differentiate between the target platforms.
October 31, 2012
Lab Rat
Cross-compiling for 32 bit on an 64 bit host is really not uncommon on Linux, I think. I am using