Complete C++11 support on Android -


i'm trying cross-compile cross-platform library have developed in order use on android. so, use arm-linux-androideabi-g++ (4.9) compiler provided ndk, , link gnu-libstdc++ present in ndk.

unfortunately, compilation won't succeed due use of c++11 features. such features specific methods present in "string.h" std::to_string or std::stof, replaced other ones if have to. use more complex ones, things "future.h" such std::future , std::async.

i've located reason of compilation error "string.h", in file "ndk/sources/cxx-stl/gnu-libstdc++/4.9/bits/basic_string.h", 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 want use   #endif 

from understood, these restrictions induced android bionic libc.

what options have solve ?

i tried use crystax ndk, solves "string.h" problem, , rather find more standard solution.

how using arm cross-compiler isn't specific android ?

thanks.

i've found solution issue.

first, use of "future.h" methods supported gnu-libstdc++ provided android ndk, missed inclusions allowing usage, bad.

next, i've taken deep library , i've figured out method causing compilation errors std::to_string. decided override following :

#if __android__  namespace std {   #ifndef to_string   inline string to_string(int _val)   {    // convert int string       char _buf[256];       sprintf(_buf, "%d", _val);       return (string(_buf));   }   #endif }  #endif 

i guess if there other unsupported c++11 methods, it's possible override them well.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -