Qt Creator: how to tell win32 from win64

送分小仙女□ 提交于 2019-12-07 19:33:23

You can use QT_ARCH variable to detect whether your configuration is 32 or 64 :

contains(QT_ARCH, i386) {
    message("32-bit")
}else {
    message("64-bit")
}

When the target is 32-bit, the variable returns i386 and in case of a 64-bit target it has the value of x86_64.

Here's how we do that:

win32 {
win32-g++:contains(QMAKE_HOST.arch, x86_64):{
    LIBS += ... #for win64
} else {
    LIBS += ... #for win32
}
}

October 2016 update. The following code works on Windows (at least with all the recent MSVC compilers - didn't test MinGW), Mac OS X (clang) and Linux (GCC). Feel free to omit the first clause and refer to QT_ARCH directly if you don't need Qt 4 support.

greaterThan(QT_MAJOR_VERSION, 4) {
    TARGET_ARCH=$${QT_ARCH}
} else {
    TARGET_ARCH=$${QMAKE_HOST.arch}
}

contains(TARGET_ARCH, x86_64) {
    ARCHITECTURE = x64
} else {
    ARCHITECTURE = x86
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!