mercredi 1 avril 2015

Complete C++11 support on Android

I'm currently trying to cross-compile a cross-platform library I have previously developed in order to use it on Android. To do so, I use the arm-linux-androideabi-g++ (4.9) compiler provided by the NDK, and I link the gnu-libstdc++ also present in the NDK.


Unfortunately, the compilation won't succeed due to the use of some C++11 features. Such features are specific methods present in "string.h" like std::to_string or std::stof, which could be replaced easily by other ones if I have to. But I also use more complex ones, like things from "future.h" such as std::future and std::async.


I've located the reason of the compilation error for "string.h", in the file "ndk/sources/cxx-stl/gnu-libstdc++/4.9/bits/basic_string.h", the following statement returning false (_GLIBCXX_USE_C99 isn't defined):



//basic_string.h

#if ((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))

//methods I want to use

#endif


From what I understood, these restrictions are induced by the Android Bionic libc.


What options do I have to solve this ?


I already tried to use the CrystaX NDK, but it only solves my "string.h" problem, and I would rather find a more standard solution.


How about using an ARM cross-compiler which isn't specific to Android ?


Thanks.


Aucun commentaire:

Enregistrer un commentaire