[Qt-interest] How do I tell with qmake whether system is 64 or 32-bit?

Bo Thorsen bo at fioniasoftware.dk
Thu Jun 9 08:40:30 CEST 2011


Den 08-06-2011 21:25, Nikos Chantziaras skrev:
> In a qmake-based project, I need to include different libraries in the
> build if the current system is 64-bit.  Something like this:
>
>     64bit {
>         LIBS += fmodex64
>     }
>     32bit {
>         LIBS += fmodex32
>     }
>
> How do I do that?

There are several ways you can go with this.

One is to use the QMAKESPEC setting:

linux-g++-32 {
   # 32 bit Linux stuff here
}

linux-g++-64 {
   # 64 bit Linux stuff here
}

Another is to have separate .pro files with all the target specific 
stuff and include(shared.pri).

You can also do something like this:

*-64:TARGET_BIT = m64
contains (TARGET_BIT, m64) {
}

Choose what works for you. Personally, I can see good reasons for all of 
them.

What I miss is that qmake can do both 32 and 64 bit builds in the same 
project. But that's not possible.

Another tip: When you do have several builds from the same sources, you 
really *must* do out of source dir builds:

projectdir/theprojecthere
projectdir/build32
projectdir/build64

cd build32; qmake ../theprojecthere/32bit.pro
cd build64; qmake ../theprojecthere/64bit.pro

In visual studio, you will probably like the -flat option with this kind 
of setup.

This way the source changes are immediately available for all your 
builds. Works well in settings where you have different projects based 
on the same code as well.

It *sucks* that QtCreator can't do this for symbian builds.

I hope this helps.

Bo Thorsen,
Expert Qt and C++ developer for hire.
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list