[QBS] Support for Qt on Android

Ch'Gans chgans at gna.org
Mon Sep 19 14:09:50 CEST 2016


On 19 September 2016 at 20:39,  <salatix at web.de> wrote:
> I followed your instructions to setup the toolchain for Android
> but when I try to build a project with
> $ qbs profile:"qt57-andgcc49_armv7
> I still get the same error:
> "The profile 'qt57-andgcc49_armv7-armv5te' does not exist.".

Weird, if your profile is named "qt57-andgcc49_armv7", why Qbs
complains about "qt57-andgcc49_armv7-armv5te"? (w/ an extra '-armv5te'
suffix)

Are you sure you have all the correct Android toolchains installed?

Here is my NDK setup (latest release available online):
krys at krys-pc:~$ ls -1 /opt/android/android-ndk-r12b/toolchains/
aarch64-linux-android-4.9
arm-linux-androideabi-4.9
llvm
mips64el-linux-android-4.9
mipsel-linux-android-4.9
x86-4.9
x86_64-4.9
krys at krys-pc:~$ ls -1 /opt/android/android-ndk-r12b/prebuilt/
android-arm
android-arm64
android-mips
android-mips64
android-x86
android-x86_64
linux-x86_64

> I also tried using older Qt Version but they did not work either.
> At the moment I don't know what else to try.

Can you try this, and send the full output (w/o any sort of editing,
ideally in an attached file):
$ qbs --version
$ qbs config --list

For a quick glance at my Qbs setup:
krys at krys-pc:~$ qbs config profiles | grep architecture
profiles.android-arm64.qbs.architecture: "arm64"
profiles.android-armv5te.qbs.architecture: "armv5te"
profiles.android-armv7a.qbs.architecture: "armv7a"
profiles.android-mips.qbs.architecture: "mips"
profiles.android-mips64.qbs.architecture: "mips64"
profiles.android-x86.qbs.architecture: "x86"
profiles.android-x86_64.qbs.architecture: "x86_64"
profiles.clang.qbs.architecture: "x86_64"
profiles.gcc.qbs.architecture: "x86_64"
krys at krys-pc:~$ qbs config profiles | grep baseProfile
profiles.android-arm64.baseProfile: "android"
profiles.android-armv5te.baseProfile: "android"
profiles.android-armv7a.baseProfile: "android"
profiles.android-mips.baseProfile: "android"
profiles.android-mips64.baseProfile: "android"
profiles.android-x86.baseProfile: "android"
profiles.android-x86_64.baseProfile: "android"
profiles.qbs_autotests.baseProfile: "gcc"
profiles.qt55-lnxclang38_64.baseProfile: "clang"
profiles.qt55-lnxgcc53_64.baseProfile: "gcc"
profiles.qt56-lnxclang38_64.baseProfile: "clang"
profiles.qt56-lnxgcc53_64.baseProfile: "gcc"
profiles.qt57-andgcc49_armv7.baseProfile: "android-armv7a"
profiles.qt57-lnxclang38_64.baseProfile: "clang"
profiles.qt57-lnxgcc53_64.baseProfile: "gcc"
krys at krys-pc:~$ qbs config profiles.android
profiles.android.Android.ndk.appStl: "gnustl_shared"
profiles.android.Android.ndk.hostArch: "linux-x86_64"
profiles.android.Android.ndk.ndkDir: "/opt/android/android-ndk-r12b"
profiles.android.Android.ndk.toolchainVersion: "4.9"
profiles.android.Android.ndk.toolchainVersionNumber: "4.9"
profiles.android.Android.sdk.ndkDir: "/opt/android/android-ndk-r12b"
profiles.android.Android.sdk.sdkDir: "/opt/android/android-sdk-linux"
profiles.android.qbs.targetOS: ["android", "linux", "unix"]
profiles.android.qbs.toolchain: "gcc"


In the past, I had to nuke my full qbs config because i mixed release
and git version of qbs. Since then I'm trying to keep my profiles
clean and well organised as I do native Linux/Mac/Windows builds using
Gitlab CI system.

So, to start from a completely clean state:
1. First, make sure that QtCreator doesn't mess up with your user's
Qbs profiles, the checkbox "Store profiles in Qt Creator settings
directory" in "Tools->Options->Qbs->Profiles" should be *checked*.
2. Then, try to do a "soft nuke", like:
$ mv ~/.config/QtProject/qbs/ ~/.config/QtProject/qbs.old
$ mv ~/.config/QtProject/qbs.conf ~/.config/QtProject/qbs.conf.old
3. Finally, start from scratch setting up Qt and Android from the
console (not from Qtc).

If you have same Android SDK/NDK, same Qbs and same setup as I
described (I hope i didn't forget anything), then it should work "same
as me"! ;)

> I would like to know which version of Qbs you were using?

Qbs 1.6.0 that comes with Qtc 4.1.0 as installed/updated by the Qt
online installer (released with Qt-5.7 I believe).

> and what the Qbs file you are building looks like?

Well, i did the test on a "big" project and i didn't save the
modifications (project is not ready for android), maybe i should try
with a very simple project.
Anyway you seem to have a problem with your Qbs profile(s), which
should be 100% independent of your Qbs building files.

Hope this helps!

Chris

> Thank you very much for your effort :)
>
> Tobias
>
>> Gesendet: Freitag, 16. September 2016 um 06:23 Uhr
>> Von: Ch'Gans <chgans at gna.org>
>> An: salatix at web.de
>> Cc: "Jake Petroules" <Jake.Petroules at qt.io>, "qbs at qt-project.org" <qbs at qt-project.org>
>> Betreff: Re: Re: [QBS] Support for Qt on Android
>>
>> On 16 September 2016 at 15:47, Ch'Gans <chgans at gna.org> wrote:
>> > On 16 September 2016 at 01:49,  <salatix at web.de> wrote:
>> >> I am building on linux. I also tried setting up the toolchain with qbs-setup-toolchains but it would not
>> >> detect the android toolchain. So I tried to configure it  in the qbs-config-ui but it didn't help either
>> >> because I still got the error of the missing armv5 profile (which does not make any sense to me
>> >> because I am using armv7...).
>> >> In Qt Creator the profile looks fine to me and the profile it refers to actually exists in $HOME/.config
>> >> /QtProject/qbs/ but as I soon as QtC tries to parse the qbs it is looking for an armv5 profile which
>> >> does not exist. The issue is similiar to one of the bugs Jake referred to https://bugreports.qt.io
>> >> /browse/QBS-881.
>> >>
>> >> Were you able to parse a qbs project with your profile for qt on Android?
>> >>
>> >> Thanks for helping with my problem :)
>> >
>> > This is how far i manage to go:
>> >
>> > # After failing setting up the toolchain manually, i discovered a new
>> > qbs tool... ;)
>> > $ qbs-setup-android --ndk-dir /opt/android/android-ndk-r12b/ --sdk-dir
>> > /opt/android/android-sdk-linux/ android
>> > # Et voilĂ ! (almost)
>> >
>> > $ qbs-setup-qt /opt/Qt/5.7/android_armv7/bin/qmake qt57-andgcc49_armv7
>> > Creating profile 'qt57-andgcc49_armv7'.
>> > WARNING: You need to set up toolchain information before you can use
>> > this Qt version for building. However, no toolchain profile was found.
>> > Either create one using qbs-setup-toolchains and set it as this
>> > profile's base profile or add the toolchain settings manually to this
>> > profile.
>> >
>> > $ qbs config profiles.qt57-andgcc49_armv7.baseProfile android-armv7a
>> >
>> > # Cannot build my project, qbs tells me to set these up
>> > $ qbs config profiles.android.Android.ndk.toolchainVersion 4.9
>> > $ qbs config profiles.android.Android.ndk.hostArch linux-x86_64
>> > $ qbs config profiles.android.Android.ndk.toolchainVersionNumber 4.9
>> >
>> > At this stage, i can run qbs, but my build fails, due to some weird
>> > STL issues i am currently investigating... (can't find "algorithm"
>> > header)
>> > Qbs tries to build my code with
>> > "-isystem/opt/android/android-ndk-r12b/sources/cxx-stl/system/include",
>> > which should be instead
>> > "-isystem/opt/android/android-ndk-r12b/sources/cxx-stl/gnu-libstdc++/4.9/include/"
>> > This is where the header is located, and this is where android-g++
>> > mkspec points to.
>> > I'm currently investigating the source of
>> > /opt/Qt/Tools/QtCreator/share/qtcreator/qbs/share/qbs/modules/cpp/android-gcc.qbs
>> >
>> > Just found a workaround, i'm pretty sure i should set that in my own
>> > qbs files, but will do for now
>> > $ qbs config profiles.android.Android.ndk.appStl gnustl_shared
>> >
>> > And now trying to solve another issue:
>> > arm-linux-androideabi-g++: error: unrecognized command line option
>> > '--fix-cortex-a8'
>> >
>> > Which is set in
>> > /opt/Qt/Tools/QtCreator/share/qtcreator/qbs/share/qbs/modules/Android/ndk/utils.js
>> > when abi is "armeabi-v7a", which is my case, ... weird!
>>
>> This one is related to the new way (Qbs-1.6) of declaring linkerFlags,
>> I got a warning message about this:
>> WARNING: Enabling linker flags compatibility mode. cpp.linkerFlags and
>> cpp.platformLinkerFlags escaping is handled automatically beginning in
>> Qbs 1.6. When upgrading to Qbs 1.6, you should only pass raw linker
>> flags to these properties; do not escape them using -Wl or -Xlinker.
>> This allows Qbs to automatically supply the correct linker flags
>> regardless of whether the linker chosen is the compiler driver or
>> system linker (see the documentation for cpp.linkerMode for more
>> information). This message can be silenced by setting your Project's
>> minimumQbsVersion to 1.6 (and the new behavior will take effect).
>>
>> My understanding is that the old behaviour is kept if i don't
>> explicitly require Qbs 1.6 (which is my case so far), yet
>> modules/Android/ndk/utils.js returns linker flags without the -Wl
>> prefix, which seems to cause troubles...
>>
>> OK, I have now switched to minimumQbsVersion="1.6", and the error is gone.
>>
>> BTW, why do i have to set minimumQbsVersion="1.6" in all my
>> sub-projects? I thought this was enough to set that up in the
>> top-level project...
>>
>> So, FYI, I am now able to build my whole project for Android as
>> described above! \o/
>> I now have to work on deployment, and see if it runs!
>>
>> Chris
>>
>>
>> >
>> > Will keep posted!
>> >
>> > Chris
>> >
>> >>
>> >>
>> >>> Gesendet: Donnerstag, 15. September 2016 um 02:07 Uhr
>> >>> Von: "Chris Gagneraud" <chgans at googlemail.com>
>> >>> An: salatix at web.de
>> >>> Cc: "Jake Petroules" <Jake.Petroules at qt.io>, "qbs at qt-project.org" <qbs at qt-project.org>
>> >>> Betreff: Re: [QBS] Support for Qt on Android
>> >>>
>> >>> > QtCreator manage its own Qbs profiles, that you cannot (easily) re-use
>> >>> > "manually".
>> >>> > Have you try to run "qbs setup-toolchain" and see if it picks up the
>> >>> > android one?
>> >>> >
>> >>> >Chris
>> >>> I've just tried here, after installing all Android, Java and Qt
>> >>> packages and selecting an android kit, QtC tells me:
>> >>>
>> >>> Cannot find the android build step.
>> >>> Error while building/deploying project XYZ (kit: Android for
>> >>> armeabi-v7a (GCC 4.9, Qt 5.7.0))
>> >>> When executing step "Deploy to Android device"
>> >>>
>> >>> Tools->Options->Qbs seems to be setup correctly
>> >>> (cpp.toolchainInstallPath/Prefix points to my Android NDK toolchain)
>> >>>
>> >>> I had a quick go at setting up the toolchain manually with
>> >>> qbs-setup-toolchain, but it refuses to detect the toolchain....
>> >>>
>> >>> Anyway, your problem seems to be different since your associated Qbs
>> >>> profile look corrupted/missing.
>> >>>
>> >>> Which platform are you building on?
>> >>>
>> >>> On Linux, QtC profiles are stored under $HOME/.config/QtProject/qtcreator/qbs
>> >>>
>> >>> Whereas your "regular" qbs profiles are stored under
>> >>> $HOME/.config/QtProject/qbs/
>> >>>
>> >>> Chris
>> >>
>> >>>
>>



More information about the Qbs mailing list