From 10:00 CET Friday 22nd November we will adjust how the server works to deal with some recently reported problems. Therefore there may be a load problem, if you experience more problems than usual trying to access the forum then please PM AndyS or any of the moderators so they can inform me.


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 change androidBuildToolsVersion
    from: androidBuildToolsVersion=29.0.0
    to: androidBuildToolsVersion=28.0.3



  • Yes. Before posting you should check previous discussions. There is a topic a couple of days ago that has your exact error message as its title



  • @mvuori Please post the link



  • @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:

    0_1560718408196_Screen Shot 2019-06-16 at 22.52.34.png

    Here is are the Android settings in Qt Creator

    0_1560718675902_Screen Shot 2019-06-16 at 22.54.37.png

    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.

    0_1560718747945_Screen Shot 2019-06-16 at 22.58.27.png

    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:

    0_1560719305132_Screen Shot 2019-06-16 at 23.07.27.png

    Unfortunately the Qt guide is not clear. I would appreciate any help.



  • I have found additional project specific settings. I think, they are derrived from a global settings template:

    0_1560758591090_Screen Shot 2019-06-17 at 09.57.56.png

    It looks korrect for me

    0_1560758712230_Screen Shot 2019-06-17 at 09.58.09.png



  • 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 change androidBuildToolsVersion
    from: androidBuildToolsVersion=29.0.0
    to: androidBuildToolsVersion=28.0.3


Log in to reply