Qt Creator的:如何从Win64中说的win32中说、Creator、Qt

2023-09-08 00:21:27 作者:国际事逼

我必须做这样的事情在一个.pro文件:

I have to do something like this in a .pro file:

win32 {
    LIBS += -L../3rdparty/libusb-win32/lib/msvc -llibusb
} else
win64 {
    LIBS += -L../3rdparty/libusb-win32/lib/msvc_x64 -llibusb
}

现在的问题是这是行不通的,它总是链接的Win32库。 有什么建议?

The problem is it doesn't work, it always links win32 library. Any suggestions?

推荐答案

您可以使用 QT_ARCH 变量来检测你的配置是32​​或64:

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")
}

当目标是32位的,变量返回 386 键,如果一个64位的目标它有 x86_64的。

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.