How to solve a build error for Android example project?
-
I followed the instruction to setup Qt Creator for Android apps. To check my setup I try to build and deploy the calculator example. I can successfully start the emulator and trigger a build for the app, but I get the following error:
/Users/andrew/Library/Android/android-ndk-r20/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot find -lc++ clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libcalculator.so] Error 1
I'm using Qt Creator on macOS Mojave. In the user's library directory I have installed the sdk and ndk, that are linked in the setup of Qt Creator. In the directory
/Users/joerg/Library/Android/android-ndk-r20/toolchains/x86-4.9/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x
I can just just two files:- crtbegin.o
- libgcc.a
Any ideas?
-
I found a solution in another thread. Thanks @Albertino
The error: cannot find -lc++ using ndk r20 can be solved like this:
https://codereview.qt-project.org/c/qt/qtbase/+/264903/9/mkspecs/android-clang/qmake.conf#34
For example to compile for android armv7 ndk r20, locate the file:
C:\Qt\5.13.0\android_armv7\mkspecs\android-clang\qmake.conf
and add the missing-nostdlib++
for android x86 (i use this for emulator), locate the file:
C:\Qt\5.13.0\android_x86\mkspecs\android-clang\qmake.conf
For error: Execution failed for task ':compileDebugAidl'
locate the file on your build directory, mine is:C:\dev_qt\experiments\build-test_qt_5_13_0_ARMv7-Release\android-build\gradle.properties
and changeandroidBuildToolsVersion
from:androidBuildToolsVersion=29.0.0
to:androidBuildToolsVersion=28.0.3
-
@mvuori In fact, forum research is always the first step. They certainly refer to this thread. I'm afraid I can't come up with a solution.
I have installed everything from the scratch: First Android Studio for macOS with a setup of the SDK and NDK amd then Qt Creator. I have installed the following packages:
Here is are the Android settings in Qt Creator
And here are my kits. I'm not sure wich kits I need. I think, the forst one for the deployment to hardware devices, the third one for virtual devices.
I think you refer to this solution in the mentioned thread:
1st: correct some invalid variables in QT's build settings/build environment (i.e. wrong slash was / instead of )... AND add some. Specifically:
ANDROID_HOME = D:\Android-SDK
ANDROID_SDK_ROOT = D:\Android-SDK
GRADLE_USER_HOME = C:\Users\pc.gradle
JAVA_HOME = D:\Program Files\Java\jdk1.8.0_201
2nd: remove the 29.0.0RC1 from Android SDK build-tools via Android Studio SDK manager. Apply.
Select 'show package details' to then be able to select the 28.0.3 version. Apply.
3rd: go into theQT project/app's folder and edit the gradle.properties file... change the line to:
androidBuildToolsVersion=28.0.3
Finally: you should probably should close and reopen QT and the project.
Build/deploy should now (hopefully/finally) work!I can't find the qt build settings as they are mentioned in the quote, just these:
Unfortunately the Qt guide is not clear. I would appreciate any help.
-
It seems to be this problem, that should be fixed in the new Qt version 5.12.4:
https://codereview.qt-project.org/c/qt/qtbase/+/264903
I have updated the Qt version in my Qt Creator installation. Unfortunately it doesn't solve the problem. At least, it is a known issue.
-
I found a solution in another thread. Thanks @Albertino
The error: cannot find -lc++ using ndk r20 can be solved like this:
https://codereview.qt-project.org/c/qt/qtbase/+/264903/9/mkspecs/android-clang/qmake.conf#34
For example to compile for android armv7 ndk r20, locate the file:
C:\Qt\5.13.0\android_armv7\mkspecs\android-clang\qmake.conf
and add the missing-nostdlib++
for android x86 (i use this for emulator), locate the file:
C:\Qt\5.13.0\android_x86\mkspecs\android-clang\qmake.conf
For error: Execution failed for task ':compileDebugAidl'
locate the file on your build directory, mine is:C:\dev_qt\experiments\build-test_qt_5_13_0_ARMv7-Release\android-build\gradle.properties
and changeandroidBuildToolsVersion
from:androidBuildToolsVersion=29.0.0
to:androidBuildToolsVersion=28.0.3