【问题标题】:How to specify libraries only for Android platform build in .pro file?如何在 .pro 文件中指定仅适用于 Android 平台构建的库?
【发布时间】:2013-08-08 21:47:39
【问题描述】:

我正在尝试使用 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)。

【问题讨论】:

标签: android qt cmake qt-creator


【解决方案1】:

这对我有用(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
}

【讨论】:

  • 似乎是 Qt 5.3 中的新功能。谢谢!
【解决方案2】:

我在 .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
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    相关资源
    最近更新 更多