Reputation: 75
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) (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/tools
by 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/sources
and extra-cmake-modules from KDE in this folder
Kirigami 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 ?
Upvotes: 3
Views: 956
Reputation: 75
Ok so I restarted everything from scracth with a fresh ubuntu 18.04 install. I have set everything up again. A few precisions :
I got the latest cmake with snap, apt installed an anterior version which gave some warning or errors.
I still went with the latest Qt, Android Sdk and Ndk versions, and I worked with the side by side ndk that can be downloaded through the Sdk manager of Android Studio.
Now the previous error was gone but there still was a problem at this step. I had to download extra-cmake-modules and install it separately in order for cmake to do its job (this is what installed the files in /usr/local/share/ECM
). At this point everything is being built without errors. All the more, Qt is able to deploy android applications from the few pre-written android-buildable examples it offers.
However some issues remain.
qmake
TEMPLATE = app
CONFIG += qt
QT += gui \
widgets
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
INCLUDEPATH += /home/dasha/marble/export/include
DEPENDPATH += /home/dasha/marble/export/include
LIBS += /home/dasha/marble/export/lib/libastro_armeabi-v7a.so \
/home/dasha/marble/export/lib/libKF5Kirigami2_armeabi-v7a.so \
/home/dasha/marble/export/lib/libmarbledeclarative_armeabi-v7a.so \
/home/dasha/marble/export/lib/libmarblewidget-qt5_armeabi-v7a.so
main.cpp
#include <QApplication>
#include <marble/MarbleWidget.h>
#include <marble/MarbleDirs.h>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
// Set Paths
Marble::MarbleDirs::setMarblePluginPath("/home/dasha/marble/export/plugins");
Marble::MarbleDirs::setMarbleDataPath("home/dasha/marble/export/data");
// Load Marble using OpenStreetMap in Mercator projection
Marble::MarbleWidget *mapWidget = new Marble::MarbleWidget;
mapWidget->setProjection(Marble::Mercator);
mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
mapWidget->setWindowTitle("Hello Marble!");
mapWidget->show();
return app.exec();
}
A few lines in each part of the humongous error message
I .example.test_: Late-enabling -Xcheck:jni
W System : ClassLoader referenced unknown path:
D PhoneWindow: windowLightStatusBar : false, disable View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
D OpenGLRenderer: Skia GL Pipeline
I QtCore : Start
I Qt : qt started
W .example.test_: Accessing hidden field Landroid/R$styleable;->ViewDrawableStates:[I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->View_background:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->View_padding:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->View_paddingLeft:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->View_paddingTop:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->View_paddingRight:I (light greylist, reflection)
W System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
W System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864)
W System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
W System.err: at android.os.Looper.loop(Looper.java:205)
W System.err: at android.app.ActivityThread.main(ActivityThread.java:6991)
W System.err: at java.lang.reflect.Method.invoke(Native Method)
W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)
W .example.test_: Accessing hidden field Landroid/R$styleable;->SeekBar:[I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->SeekBar_thumb:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->SeekBar_thumbOffset:I (light greylist, reflection)
W .example.test_: Accessing hidden field Lcom/android/internal/R$attr;->switchStyle:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->Switch:[I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->LinearLayout_divider:I (light greylist, reflection)
W .example.test_: Accessing hidden field Landroid/R$styleable;->LinearLayout_showDividers:I (light greylist, reflection)
W .example.test_: Accessing hidden field
Landroid/R$styleable;->LinearLayout_dividerPadding:I (light greylist, reflection)
E AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread
E AndroidRuntime: Process: org.qtproject.example.test_3, PID: 31374
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libastro_armeabi-v7a.so" not found
E AndroidRuntime: at java.lang.Runtime.load0(Runtime.java:928)
E AndroidRuntime: at java.lang.System.load(System.java:1633)
E AndroidRuntime: at org.qtproject.qt5.android.QtNative$4.run(QtNative.java:275)
E AndroidRuntime: at org.qtproject.qt5.android.QtThread$2.run(QtThread.java:87)
E AndroidRuntime: at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
I Process : Sending signal. PID: 31374 SIG: 9
"org.qtproject.example.test_3" died.
And it seems that some library hasn't been "exported" and cannot be opened (libastro
)...
Another remark : adding thses two lines in main.cpp removes all error messages but the app crashes anyway.
Marble::MarbleDirs::setMarblePluginPath("/home/dasha/marble/export/plugins");
Marble::MarbleDirs::setMarbleDataPath("home/dasha/marble/export/data");
~/marble/sources/src/apps/marble-maps/create-apk.py --target MarbleMaps.apk ../export
from ~/marble/sources
:Cannot find ../export/share/deploy-marble-maps.json. Is ../export really a Marble Android installation?
I don't know why this file hasn't been installed while I can found deploy-behaim.json
in the mentioned folder...
I could try installing older version of Qt, Android Sdk and Ndk but I will most likely run into other similar errors anyway, and I have don't have the time to go through that. This installation is too much of a hassle for me, I think I will go with QtLocation
etc. for my application, and learn some QML, as it seems to be an easier and a more future-proof method. If you know what is happening however, please feel free to explain what has been going wrong !
Upvotes: 2