Android Compiler Errors using STL

I am porting an iOS Cocos2D-X game to Android and am having a terrible time getting STL to behave properly.

Initially, I was compiling with what I believe for some reason is the default Cocos2D-X project setting of

APP_STL := gnustl_static

This caused a lot of errors related to ‘to_string’ is not a member of ‘std’. This is pretty well documented and known and was not really surprising after reading about it. I then proceeded to try both

APP_STL := c++_static

and

APP_STL := c++_shared

Both of these gave me a large amount of STL errors when compiling. Here is a sample of the errors which are representative off all of them:

In file included from /Users/davidholtkamp/Development/igun-pro-2-client-cpp/cocos2d/cocos/./base/CCConsole.h:44:0,
from /Users/davidholtkamp/Development/igun-pro-2-client-cpp/cocos2d/cocos/./base/CCConsole.cpp:25:
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/map: In instantiation of ‘union std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>’:
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2088:55: required by substitution of ‘template<class _Tp, class _Arg> typename std::__ndk1::__select_2nd<decltype ((declval<_Tp>)()=(declval<_Arg>)()), std::__ndk1::integral_constant<bool, true> >::type std::__ndk1::__is_assignable_test(int) [with _Tp = std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&; _Arg = std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&]’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2097:64: required from ‘struct std::__ndk1::__is_assignable_imp<std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&, std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&, false>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2106:8: required from ‘struct std::__ndk1::is_assignable<std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&, std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:3774:29: required from ‘struct std::__ndk1::is_nothrow_assignable<std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&, std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:3841:50: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2088:55: required by substitution of ‘template<class _Tp, class _Arg> typename std::__ndk1::__select_2nd<decltype ((declval<_Tp>)()=(declval<_Arg>)()), std::__ndk1::integral_constant<bool, true> >::type std::__ndk1::__is_assignable_test(int) [with _Tp = cocos2d::Console::Command&; _Arg = cocos2d::Console::Command&&]’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2097:64: required from ‘struct std::__ndk1::__is_assignable_imp<cocos2d::Console::Command&, cocos2d::Console::Command&&, false>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2106:8: required from ‘struct std::__ndk1::is_assignable<cocos2d::Console::Command&, cocos2d::Console::Command&&>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2127:50: required from ‘struct std::__ndk1::is_move_assignablecocos2d::Console::Command
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/utility:506:63: required from ‘struct std::__ndk1::pair<const std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>’
/Users/davidholtkamp/Development/igun-pro-2-client-cpp/cocos2d/cocos/./base/CCConsole.cpp:331:28: required from here
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/map:624:16: error: ‘std::__ndk1::__value_type<_Key, _Value>::__cc’ has incomplete type
value_type __cc;
^
In file included from /Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/__functional_base:19:0,
from /Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/thread:90,
from /Users/davidholtkamp/Development/igun-pro-2-client-cpp/cocos2d/cocos/./base/CCConsole.h:42,
from /Users/davidholtkamp/Development/igun-pro-2-client-cpp/cocos2d/cocos/./base/CCConsole.cpp:25:
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/utility:312:29: error: declaration of ‘std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>::value_type {aka struct std::__ndk1::pair<const std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>}’
struct _LIBCPP_TEMPLATE_VIS pair
^
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/utility: In instantiation of ‘struct std::__ndk1::pair<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>’:
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/map:625:21: required from ‘union std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2088:55: required by substitution of ‘template<class _Tp, class _Arg> typename std::__ndk1::__select_2nd<decltype ((declval<_Tp>)()=(declval<_Arg>)()), std::__ndk1::integral_constant<bool, true> >::type std::__ndk1::__is_assignable_test(int) [with _Tp = std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&; _Arg = std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&]’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2097:64: required from ‘struct std::__ndk1::__is_assignable_imp<std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&, std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&, false>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2106:8: required from ‘struct std::__ndk1::is_assignable<std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&, std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:3774:29: required from ‘struct std::__ndk1::is_nothrow_assignable<std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&, std::__ndk1::__tree<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::__map_value_compare<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>, std::__ndk1::less<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator > >, true>, std::__ndk1::allocator<std::__ndk1::__value_type<std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command> > >&&>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:3841:50: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2088:55: required by substitution of ‘template<class _Tp, class _Arg> typename std::__ndk1::__select_2nd<decltype ((declval<_Tp>)()=(declval<_Arg>)()), std::__ndk1::integral_constant<bool, true> >::type std::__ndk1::__is_assignable_test(int) [with _Tp = cocos2d::Console::Command&; _Arg = cocos2d::Console::Command&&]’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2097:64: required from ‘struct std::__ndk1::__is_assignable_imp<cocos2d::Console::Command&, cocos2d::Console::Command&&, false>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2106:8: required from ‘struct std::__ndk1::is_assignable<cocos2d::Console::Command&, cocos2d::Console::Command&&>’
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:2127:50: required from ‘struct std::__ndk1::is_move_assignablecocos2d::Console::Command
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/utility:506:63: required from ‘struct std::__ndk1::pair<const std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator >, cocos2d::Console::Command>’
/Users/davidholtkamp/Development/igun-pro-2-client-cpp/cocos2d/cocos/./base/CCConsole.cpp:331:28: required from here
/Users/davidholtkamp/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/utility:506:63: error: incomplete type ‘std::__ndk1::is_move_assignablecocos2d::Console::Command’ used in nested name specifier
is_move_assignable<first_type>::value &&

This project was created using the newest version of Cocos2D-X a few months back. I am new to Android development so I have tried many different things to no avail on this. Any pointers to why this is happening would be much appreciated.

search these forums, this has been answered several times.

I realize this might be a stupid question, but I have searched the internet and this forum for quite some time before posting and then again after you said it was answered here. Even a one word answer or clue would help if you already know what it is.

The only person who has had the same errors is this person earlier this year:

And it was never answered either. Any more information on what you are referring to would be helpful and would help us actually have answers in the end of threads. Happy to fill in my own answer if you could direct me to and of the thread you are referring to.

Thanks for the help!

APP_STL := gnustl_static is correct.

You need to implement to_string yourself: Android: error: 'to_string' is not a member of 'std' NDK10c cocos 3.10v

Use Android Studio as building from the command-line is now deprecated because Google removed the android command-line tool that our cocos tool depended upon.

As a well-known case,
std::to_string is not available for Android NDK.
Instead, you can use cocos2d::StringUtils::format.

example:

int value = 100;
std::string str = StringUtils::format ("%d", value);

Likewise, std::stoi can not be used as well.
That is, Android NDK is not a complete C ++ 11.

Use std::stringstream as an alternative to std::stoi.

int strToInt(const std::string & str) {
    std::stringstream in(str);
    int v = 0;
    in >> v;

    return v;
}

int value = strToInt("100");
1 Like

Thanks for the response! I was under the impression that Cocos was about to move to a different STL library as Android changes the default. I’ve also seen a lot of reports of people successfully using

APP_STL := c++_static

and am still curious as to why the other compiler errors happen when I try. For the time being I will implement my own wrapper of it as I am using 3rd party libraries which depend on it.

APP_ABI := armeabi-v7a
APP_STL := c++_shared
APP_CPPFLAGS := $(MY_CPPFLAGS) -frtti -std=c++11 -fsigned-char
APP_LDFLAGS := -L$(STL_PATH) -latomic

did you add -std=c++11 to APP_CPPFLAGS?

Yes, here are my configurations:

APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char -U__STRICT_ANSI__
APP_LDFLAGS := -latomic

Which NDK version are you using?

I am using NDK version 16.1.4479499

I tried using c++_static for my STL to compile the latest version of the CppTests that comes with Cocos2D and it still has the same compiler errors with CConsole and some Cocos UI classes. This must be either my installation or Cocos is no longer compatible with c++_static like some suggest.

Actually, I think all the other messages are warnings. It seems CCConsole may be causing all the problems.

I am using: APP_STL := c++_static but with Android Studio.

Yes, I am using Android Studio as well with the CppTests project exactly as it comes except with the changed APP_STL field, and it is still having this error. I’m going to dig into my system setup and the root cause of these errors and hopefully find a solution as others seem to not be having this issue.

Ok, I think I may have found my problem. Apparently I need to switch to the clang compiler. I attempted to do this in the makefile at one time, but I think gradle may have overridden it. I changed build.gradle to:

arguments ‘NDK_TOOLCHAIN_VERSION=clang’

and it seems to have gotten past the cryptic errors.

1 Like

Indeed! You can always run cocos new ... and take a look at the proj.android folder for settings.

Instead of using std::to_string() use cocos2d::StringUtils::toString() which is alternative to it.

As long as portability to other platforms isn’t a concern, this could be done…

Well worked for me (windows/android with different versions atleast), I don’t have iphone to test it though.

The main problem for me, and I think many who would need the above solution of switching to the new STL and Clang, is that its messy to switch 3rd party libraries over to new methods. For instance, I was using the popular JSON library which actually had a rather long issue thread on GitHub of a user trying to get it working for Cocos.