Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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).

like image 812
Chaos_99 Avatar asked Aug 07 '13 13:08

Chaos_99


2 Answers

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
}
like image 198
mchiasson Avatar answered Oct 20 '22 16:10

mchiasson


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
}
like image 44
landrew Avatar answered Oct 20 '22 16:10

landrew