Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Qt Creator to use Clang with Qt for Android

It seems that GCC is now deprecated and will be removed from the Android NDK; Clang will be used instead. That being said Android NDK will never have support for GCC 5 and no updates will be made in regards to GCC.

That being said I wanted to use Qt for Android with Clang and it seems work has been done in this direction for Qt 5.7.1: https://bugreports.qt.io/browse/QTBUG-50724 but I don't know how to configure Qt Creator to use Clang for the Android configuration and Qt Creator doesn't autodetect the configuration:

enter image description here

Does anyone know how to configure Qt Creator and where the Clang compilers for Android are? It seems that they are somewhere in /Users/user/Library/Android/sdk/ndk-bundle/ but I just can't seem to get it right. I use Qt Creator 4.2.2.

Is it possible to use Qt for Android with Clang?

like image 919
Jacob Krieg Avatar asked Apr 27 '17 09:04

Jacob Krieg


People also ask

Can Qt be used for Android?

Qt for Android enables you to develop Qt applications for Android devices, and supports a wide range of features and use-cases. To download and install Qt for Android, follow the instructions on the Getting Started with Qt for Android page. To build Qt from source, see Building from Source.

Is Qt good for Android development?

“Qt is stronger when it comes to the mobile UX, the Android development environment offers better developer assistance and debugging, and both are strong when it comes to manipulating media files.


1 Answers

I have had some success with manually adding C and C++ clang compilers.

Compiler path: /home/david/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++

Platform codegen flags: -target armv7-none-linux-androideabi

You will need Qt built the same way! My configure command is:

export OPENSSL_LIBS='-L/home/david/QtAndroidBuild/OpenSSL/libs/armeabi-v7a/lib -lssl -lcrypto'
./configure -xplatform android-clang \
    --disable-rpath \
    -nomake tests \
    -nomake examples \
    -android-ndk /home/david/Android/Sdk/ndk-bundle \
    -android-sdk /home/david/Android/Sdk \
    -android-ndk-host linux-x86_64 \
    -android-toolchain-version 4.9 \
    -android-arch armeabi-v7a \
    -android-ndk-platform android-19 \
    -skip qttranslations \
    -skip qtserialport \
    -skip qt3d  \
    -skip qtcharts \
    -skip qtdoc \
    -skip qtmultimedia \
    -openssl-linked \
    -no-warnings-are-errors \
    -opensource \
    -confirm-license  \
    -I /home/david/QtAndroidBuild/OpenSSL/libs/armeabi-v7a/include \
    -prefix /home/david/apps/QtAndroidClang \
    -recheck

You may not need/want OpenSSL so adjust as necessary. I Build 5.10.1.

like image 153
David Netherwood Avatar answered Sep 30 '22 14:09

David Netherwood