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. No c++11 support for Android
Forum Update on Monday, May 27th 2025

No c++11 support for Android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
androidc++11library
14 Posts 8 Posters 6.7k 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.
  • J Offline
    J Offline
    JaTe
    wrote on 16 Mar 2018, 15:19 last edited by JaTe
    #1

    I'm building an Android app in qt and need c++11 support for a 3rd party library.

    The app builds fine with my desktop kit (MinGW 5.3.0) but I get multiple errors for my Android kit, like:

    'to_string' is not a member of 'std'
    'strtof' ist not a member of 'std'
    etc.

    My android kit (auto detected):
    Android for armeabi-v7a (GCC 4.9, Qt 5.10.0 for Android armv7)
    Compiler: Android GCC (C, arm-4.9)
    Compiler: Android GCC (c++, arm-4.9)

    NDK Version: r10e

    I've already tried to add these flags to the pro file:

    CONFIG += c++11
    QMAKE_CXXFLAGS += -std=c++11
    QMAKE_LFLAGS +=  -std=c++11
    

    The common solution seems to be adding

    APP_STL:=c++_static
    

    to your Android.mk file, but as far as I know that doesn't exist when using qt.

    These are my CXXFLAGS from the build directory make file:

    CXXFLAGS      = -D__ANDROID_API__=16 --sysroot=C:\Android\NDK\android-ndk-r10e/platforms/android-16/arch-arm/ -isystem C:\Android\NDK\android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem C:\Android\NDK\android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include -fstack-protector-strong -DANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-builtin-memmove -std=c++11 -g -g -marm -O0 **-std=gnu++11** -Wall -W -D_REENTRANT -fPIC $(DEFINES)
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SR__
      wrote on 16 Mar 2018, 17:37 last edited by
      #2

      And with NDK r10e ?

      See https://wiki.qt.io/Qt_for_Android_known_issues and http://doc.qt.io/qt-5/androidgs.html

      1 Reply Last reply
      1
      • J Offline
        J Offline
        JaTe
        wrote on 17 Mar 2018, 22:48 last edited by
        #3

        I've tried 10e as well. Unfortunately no success.

        It seems like the Android GCC compiler does not compile against the standard library :/

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Mar 2018, 23:01 last edited by
          #4

          Hi,

          This stack overflow answer shows how to implement to_string as well as links to here which gives more details about string support in the NDK.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply 21 Mar 2018, 13:25
          1
          • S SGaist
            18 Mar 2018, 23:01

            Hi,

            This stack overflow answer shows how to implement to_string as well as links to here which gives more details about string support in the NDK.

            J Offline
            J Offline
            JaTe
            wrote on 21 Mar 2018, 13:25 last edited by
            #5

            @SGaist Since I'm getting multiple errors implementing all those functions isn't really an option. I've heard about the Android.mk fix, but there isn't really such a file in Qt, is there?

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JaTe
              wrote on 21 Mar 2018, 13:34 last edited by
              #6

              I've updated my question, as it seems to be c++11 support more than include problems.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                Gourmet
                wrote on 21 Mar 2018, 13:59 last edited by
                #7

                Use Linux workstation with complete GNU CPP compiler instead of castrated Windows MinGW - and you will get full C++11 support. I do that just like that exactly. It is much more comfortable develop and debug Android apps on Linux rather than on Windows. Cause Android itself is Linux by nature...

                J 1 Reply Last reply 22 Mar 2018, 06:36
                2
                • G Gourmet
                  21 Mar 2018, 13:59

                  Use Linux workstation with complete GNU CPP compiler instead of castrated Windows MinGW - and you will get full C++11 support. I do that just like that exactly. It is much more comfortable develop and debug Android apps on Linux rather than on Windows. Cause Android itself is Linux by nature...

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 22 Mar 2018, 06:36 last edited by
                  #8

                  @Gourmet He is building for Android using the official compiler from NDK I guess, not MinGW.
                  And why do you think MinGW is "castrated"? It is simply GCC ported to Windows.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    Eeli K
                    wrote on 25 Oct 2018, 12:15 last edited by
                    #9

                    Does anyone have a real solution for this, not strings but the whole bunch? I don't know the details, but I have an app which I naively developed only with the Desktop kit and it should really work in Android. Do I have to spend a couple of days to refactor to C++98?

                    Library problems:

                    C:\Users\Eeli\Documents\Kaiku\panelsdata.cpp:149: error: 'class std::initializer_list<std::vector<_WALL_PANEL> >' has no member named 'erase'
                    

                    But also non-library:

                    //code
                    for (WALL_PANEL& p: panels) {
                            p.Zpos++;
                    
                    C:\Users\Eeli\Documents\Kaiku\panelsdata.cpp:158: error: 'const class std::vector<_WALL_PANEL>' has no member named 'Zpos'
                             p.Zpos++;
                               ^
                    

                    And about 10 others in just 1 file. This all compiles and runs fine with Creator 4.7.1 and Qt 5.11.2 with the default Desktop Kit on Windows.

                    So, really, no GCC 5.3 or C++11 for Android?

                    J 1 Reply Last reply 25 Oct 2018, 12:24
                    0
                    • E Eeli K
                      25 Oct 2018, 12:15

                      Does anyone have a real solution for this, not strings but the whole bunch? I don't know the details, but I have an app which I naively developed only with the Desktop kit and it should really work in Android. Do I have to spend a couple of days to refactor to C++98?

                      Library problems:

                      C:\Users\Eeli\Documents\Kaiku\panelsdata.cpp:149: error: 'class std::initializer_list<std::vector<_WALL_PANEL> >' has no member named 'erase'
                      

                      But also non-library:

                      //code
                      for (WALL_PANEL& p: panels) {
                              p.Zpos++;
                      
                      C:\Users\Eeli\Documents\Kaiku\panelsdata.cpp:158: error: 'const class std::vector<_WALL_PANEL>' has no member named 'Zpos'
                               p.Zpos++;
                                 ^
                      

                      And about 10 others in just 1 file. This all compiles and runs fine with Creator 4.7.1 and Qt 5.11.2 with the default Desktop Kit on Windows.

                      So, really, no GCC 5.3 or C++11 for Android?

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 25 Oct 2018, 12:24 last edited by
                      #10

                      @Eeli-K What type is WALL_PANEL?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      E 1 Reply Last reply 25 Oct 2018, 12:53
                      0
                      • sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on 25 Oct 2018, 12:25 last edited by
                        #11

                        Here's a possible hack around it: https://forum.qt.io/topic/38949/stl-on-android

                        Another possibility: https://github.com/nlohmann/json/issues/219#issuecomment-221686166

                        Or wait for Qt 5.12 which switches to clang on Android, and supports much more modern c++.

                        (Z(:^

                        1 Reply Last reply
                        1
                        • J jsulm
                          25 Oct 2018, 12:24

                          @Eeli-K What type is WALL_PANEL?

                          E Offline
                          E Offline
                          Eeli K
                          wrote on 25 Oct 2018, 12:53 last edited by
                          #12

                          @jsulm It's just a simple struct with byte-long fields.

                          @sierdzio Good news about 5.12, but the prototype must be ready tomorrow :) I'll see the hacks and maybe try 5.12 beta.

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            Eeli K
                            wrote on 29 Oct 2018, 17:27 last edited by
                            #13

                            I got apk package done with Qt 5.12b and Linux. Windows gives me problems. I'll start another thread for it because it's not directly related.

                            E 1 Reply Last reply 29 Oct 2018, 19:25
                            0
                            • E Eeli K
                              29 Oct 2018, 17:27

                              I got apk package done with Qt 5.12b and Linux. Windows gives me problems. I'll start another thread for it because it's not directly related.

                              E Offline
                              E Offline
                              Eeli K
                              wrote on 29 Oct 2018, 19:25 last edited by
                              #14

                              No need for another thread, I got it working. Here are the android related package versions which finally made it to work in case someone else has troubles:
                              0_1540840385190_4fa02fd1-7668-4c41-a244-2537d0fb3016-image.png

                              The latest JDK and NDK didn't work.

                              I hope they fix the name strings for the next beta. It's annoying and confusing to have "GCC" everywhere even though it really uses clang.

                              1 Reply Last reply
                              2

                              • Login

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