Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to solve a build error for Android example project?
Forum Update on Monday, May 27th 2025

How to solve a build error for Android example project?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 3 Posters 2.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    a.burks
    wrote on 16 Jun 2019, 09:48 last edited by a.burks
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      a.burks
      wrote on 22 Jun 2019, 14:50 last edited by
      #7

      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

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mvuori
        wrote on 16 Jun 2019, 10:32 last edited by
        #2

        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

        R A 2 Replies Last reply 16 Jun 2019, 16:30
        0
        • M mvuori
          16 Jun 2019, 10:32

          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

          R Offline
          R Offline
          Refi
          wrote on 16 Jun 2019, 16:30 last edited by
          #3

          @mvuori Please post the link

          1 Reply Last reply
          0
          • M mvuori
            16 Jun 2019, 10:32

            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

            A Offline
            A Offline
            a.burks
            wrote on 16 Jun 2019, 21:09 last edited by
            #4

            @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.

            A 1 Reply Last reply 17 Jun 2019, 08:06
            0
            • A a.burks
              16 Jun 2019, 21:09

              @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.

              A Offline
              A Offline
              a.burks
              wrote on 17 Jun 2019, 08:06 last edited by
              #5

              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

              1 Reply Last reply
              0
              • A Offline
                A Offline
                a.burks
                wrote on 20 Jun 2019, 14:41 last edited by
                #6

                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.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  a.burks
                  wrote on 22 Jun 2019, 14:50 last edited by
                  #7

                  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

                  1 Reply Last reply
                  2

                  7/7

                  22 Jun 2019, 14:50

                  • Login

                  • Login or register to search.
                  7 out of 7
                  • First post
                    7/7
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved