How to specify libraries only for Android platform build in .pro file?

半世苍凉 提交于 2019-12-21 04:19:12

问题


I'm trying to use QtCreator (2.7.2) + QT (5.1.0) to build an application that runs on both desktop (Linux) and mobile (Android) platforms.

To achieve this, I need to use different pre-built libraries depending on the target platform. How do I specify this in the .pro file?

The wizard only offers linux/mac/windows as platform choice like

unix:!mac {
message("* Using settings for Unix/Linux.")
LIBS += -L/path/to/linux/libs
}

I've tried

android { 
message("* Using settings for Android.")
LIBS += -L/path/to/android/libs
}

But with both build targets only the unix:!mac gets executed/evaluated.

So my question is: How to detect the build target (called "Kits" now in QtCreator) in the .pro file and change library definitions accordingly?

I've so far only found out how to specify the platform (which seems to be the platform I'm building ON and not FOR) or the build variant RELEASE/DEBUG. Other things I've found say I should prefix the LIB+= with the target platform like win32:LIB+=. But again, this won't work with android. Maybe I'm using a wrong syntax for the platform (android 4.2 on an arm-v7).


回答1:


this works for me (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
}



回答2:


I'm using this in a .pro file, maybe it helps:

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
}


来源:https://stackoverflow.com/questions/18104716/how-to-specify-libraries-only-for-android-platform-build-in-pro-file

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