Any way to detect 64 bit vs 32 bit machine in QT Creator .pro file?
I am linking to a .a lib and need to link to the right version for the machine that's compiling. Is there a way to detect the type of machine in a .pro 开发者_开发百科file in linux? I found this article, but they only discuss Windows: http://developer.qt.nokia.com/faq/answer/how_can_i_detect_in_the_.pro_file_if_i_am_compiling_for_a_32_bit_or_a_64_bi
Edit: The .a library is Gtest. Another way to solve my problem would be to somehow build a .a file with g++ that will work on either 32-bit or 64-bit platforms. Is that possible?
By doing your conditional on a mkspec, (see Platform Scope Values here), you can check for a very large variety of compiler/platform.
My mkspec directory (Linux64 machine), gives the following differentiations:
aix-g++/ irix-g++-64/ qconfig.pri wince50standard-armv4i-msvc2005/
aix-g++-64/ linux-cxx/ qws/ wince50standard-armv4i-msvc2008/
aix-xlc/ linux-ecc-64/ sco-cc/ wince50standard-mipsii-msvc2005/
aix-xlc-64/ linux-g++/ sco-g++/ wince50standard-mipsii-msvc2008/
common/ linux-g++-32/ solaris-cc/ wince50standard-mipsiv-msvc2005/
cygwin-g++/ linux-g++-64/ solaris-cc-64/ wince50standard-mipsiv-msvc2008/
darwin-g++/ linux-g++-maemo/ solaris-cc-64-stlport/ wince50standard-sh4-msvc2005/
default@ linux-icc/ solaris-cc-stlport/ wince50standard-sh4-msvc2008/
features/ linux-icc-32/ solaris-g++/ wince50standard-x86-msvc2005/
freebsd-g++/ linux-icc-64/ solaris-g++-64/ wince50standard-x86-msvc2008/
freebsd-g++34/ linux-kcc/ symbian/ wince60standard-armv4i-msvc2005/
freebsd-g++40/ linux-llvm/ symbian-abld/ wince60standard-x86-msvc2005/
freebsd-icc/ linux-lsb-g++/ symbian-sbsv2/ wincewm50pocket-msvc2005/
hpux-acc/ linux-pgcc/ tru64-cxx/ wincewm50pocket-msvc2008/
hpux-acc-64/ lynxos-g++/ tru64-g++/ wincewm50smart-msvc2005/
hpux-acc-o64/ macx-g++/ unixware-cc/ wincewm50smart-msvc2008/
hpux-g++/ macx-g++40/ unixware-g++/ wincewm60professional-msvc2005/
hpux-g++-64/ macx-g++42/ unsupported/ wincewm60professional-msvc2008/
hpuxi-acc-32/ macx-icc/ win32-borland/ wincewm60standard-msvc2005/
hpuxi-acc-64/ macx-llvm/ win32-g++/ wincewm60standard-msvc2008/
hpuxi-g++-64/ macx-pbuilder/ win32-icc/ wincewm65professional-msvc2005/
hurd-g++/ macx-xcode/ win32-msvc2003/ wincewm65professional-msvc2008/
irix-cc/ macx-xlc/ win32-msvc2005/
irix-cc-64/ netbsd-g++/ win32-msvc2008/
irix-g++/ openbsd-g++/ win32-msvc2010/
In the .pro file, you can have things like:
mkspec:VAR += special_spec_var_value
So for example, when compiling for arm, to link my touchscreen lib I do:
linux-arm-g++:LIBS += -lts
精彩评论