我正在尝试使用QtCreator(2.7.2)+ QT(5.1.0)构建一个可在桌面(Linux)和移动(Android)平台上运行的应用程序。
为实现这一目标,我需要根据目标平台使用不同的预构建库。 如何在.pro文件中指定它?
该向导仅提供linux / mac / windows作为平台选择,如
unix:!mac {
message("* Using settings for Unix/Linux.")
LIBS += -L/path/to/linux/libs
}
我试过
android {
message("* Using settings for Android.")
LIBS += -L/path/to/android/libs
}
但是对于两个构建目标,只有unix:!mac
被执行/评估。
所以我的问题是:如何在.pro文件中检测构建目标(现在在QtCreator中称为“Kits”)并相应地更改库定义?
我到目前为止只发现了如何指定平台(这似乎是我正在构建的平台而不是FOR)或构建变体RELEASE / DEBUG。
我发现的其他事情说我应该在LIB+=
前加上win32:LIB+=
之类的目标平台。但同样,这不适用于android
。也许我在平台上使用了错误的语法(arm-v7上的android 4.2)。
答案 0 :(得分:16)
这对我有用(Qt 5.3.2)
linux:!android {
message("* Using settings for Unix/Linux.")
LIBS += -L/path/to/linux/libs
}
android {
message("* Using settings for Android.")
LIBS += -L/path/to/android/libs
}
答案 1 :(得分:4)
我在.pro文件中使用它,也许有帮助:
unix:!macx:
{
android:
{
INCLUDEPATH += "/usr/lib/boost/boost_1_47_0" \
inkscape
}
!android:
{
INCLUDEPATH += $$(BOOST_PATH) \
inkscape
}
}
macx:
{
INCLUDEPATH += "../../../../boost_1_54_0" \#$$(BOOST_PATH) \
inkscape
}