I am trying to build Marble, a Qt library for maps and navigation, for Android. For the moment I'd rather go this way than using QtLocation and QML because I am way more comfortable with a C++ interface. To do so I am following this guide : https://community.kde.org/Marble/AndroidCompiling
My specs are the following :
Kali Linux on a VirtualBox VM (release 2020.1, codename kali-rolling) (yes I know I am a bit of an icy fuckboy... And truth is I am a bit of a beginner on Linux but the tools it provides are useful regarding the projects I am currently working on. Moreover, for a previous project, I had already installed Qt and the required Android tools as described here : https://doc.qt.io/qt-5/android-getting-started.html.
Qt 5.14.1 and Qt Creator 4.11.1
Android Sdk : Android SDK buils-tools 30-rc1, LLDB, NDK (side by side), Android SDK command-line Tools (latest), CMake, Android SDK Platform-Tools (29.0.6), Android SDK Tools (Obsolete) (26.1.1) but replaced
Sdk/toolsby SDK Tools version r25.2.5 as instructed by the guide; Sdk platforms 10 and 20 to 29 are installed.Android Ndk : android-ndk-r21 (latest download). There is a ndk folder in the Sdk installation (
Sdk/ndk/21.0.6113669/) I don't know if they are the same, nor if they are the same version. Anyway it doesn't work with either of them.JDK : I have installed openjdk 8 (
/usr/lib/jvm/java-8-openjdk-amd64) because the Sdk could only work with "Java 1.8" as told by QtCreator.CMake : version 3.16.3
Ant : version 1.10.7
Marble sources in
~/marble/sourcesand extra-cmake-modules from KDE in this folderKirigami in
~/kirigami
Ok so from there I follow the guide, define the the envrionment variables as needed :
export ANDROID_NDK_ROOT=~/Android/android-ndk-r21
export ANDROID_NDK=$ANDROID_NDK_ROOT
export ANDROID_SDK_ROOT=~/Android/Sdk
export ANT=/usr/bin/ant
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export Qt5_android=/opt/Qt/5.14.1/android
export ECM=~/marble/sources/extra-cmake-modules
export ANDROID_PLATFORM=android-29
And that's when I can't configure with cmake when running the following command from ~/kirigami/build :
cmake .. -DCMAKE_TOOLCHAIN_FILE=${ECM}/toolchain/Android.cmake -DCMAKE_PREFIX_PATH=${Qt5_android} -DCMAKE_INSTALL_PREFIX=~/marble/export -DECM_DIR=/usr/local/share/ECM/cmake
I get the following error :
-- You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=<targetname> and -DANDROID_APK_DIR=<paths>
-- Android: Targeting API '21' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
-- You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=<targetname> and -DANDROID_APK_DIR=<paths>
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 9.0.8
-- The CXX compiler identification is Clang 9.0.8
-- Check for working C compiler: /home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/kali/kirigami/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_be61f/fast && /usr/bin/make -f CMakeFiles/cmTC_be61f.dir/build.make CMakeFiles/cmTC_be61f.dir/build
make[1]: Entering directory '/home/kali/kirigami/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_be61f.dir/testCCompiler.c.o
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/home/kali/Android/android-ndk-r21/sysroot -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions -g -fPIE -o CMakeFiles/cmTC_be61f.dir/testCCompiler.c.o -c /home/kali/kirigami/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_be61f
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_be61f.dir/link.txt --verbose=1
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/home/kali/Android/android-ndk-r21/platforms/android-21/arch-arm -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions -g -Wl,--fix-cortex-a8 -fPIE -pie -Wl,--gc-sections -Wl,-z,nocopyreloc CMakeFiles/cmTC_be61f.dir/testCCompiler.c.o -o cmTC_be61f -latomic -lm
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lunwind
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lunwind
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_be61f.dir/build.make:87: cmTC_be61f] Error 1
make[1]: Leaving directory '/home/kali/kirigami/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_be61f/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:6 (project)
-- Configuring incomplete, errors occurred!
See also "/home/kali/kirigami/build/CMakeFiles/CMakeOutput.log".
See also "/home/kali/kirigami/build/CMakeFiles/CMakeError.log".
And here is CMakeOutput.log :
The target system is: Android - 21 - armv7-a
The host system is: Linux - 5.4.0-kali3-amd64 - x86_64
Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
Compiler: /home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
Build flags:
Id flags:
The output was:
0
Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out"
The C compiler identification is Clang, found in "/home/kali/kirigami/build/CMakeFiles/3.16.3/CompilerIdC/a.out"
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: /home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
Build flags:
Id flags:
The output was:
0
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is Clang, found in "/home/kali/kirigami/build/CMakeFiles/3.16.3/CompilerIdCXX/a.out"
And CMakeError.log :
Determining if the C compiler works failed with the following output:
Change Dir: /home/kali/kirigami/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_be61f/fast && /usr/bin/make -f CMakeFiles/cmTC_be61f.dir/build.make CMakeFiles/cmTC_be61f.dir/build
make[1]: Entering directory '/home/kali/kirigami/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_be61f.dir/testCCompiler.c.o
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/home/kali/Android/android-ndk-r21/sysroot -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions -g -fPIE -o CMakeFiles/cmTC_be61f.dir/testCCompiler.c.o -c /home/kali/kirigami/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_be61f
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_be61f.dir/link.txt --verbose=1
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/home/kali/Android/android-ndk-r21/platforms/android-21/arch-arm -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions -g -Wl,--fix-cortex-a8 -fPIE -pie -Wl,--gc-sections -Wl,-z,nocopyreloc CMakeFiles/cmTC_be61f.dir/testCCompiler.c.o -o cmTC_be61f -latomic -lm
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lunwind
/home/kali/Android/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lunwind
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_be61f.dir/build.make:87: cmTC_be61f] Error 1
make[1]: Leaving directory '/home/kali/kirigami/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_be61f/fast] Error 2
So there seems to be a problem with some linker unable to find libunwind or something like that. I have tried installing libunwind running sudo apt install libunwind-dev as a first guess, but that didn't resolve anything. I am not comfortable enough with cmake, linking etc. to understand and pinpoint the problem, and I can't find any useful information about this issue online. Can you please help me ?