No c++11 support for Android



  • 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)
    




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

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


  • Lifetime Qt Champion

    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.



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



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



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


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.