I am trying to use NDK 5 full C ++ gnustl:
In CPLUSPLUS-SUPPORT.html indicated:
The NDK toolchain supports C ++ exceptions, since NDK r5, however, all C ++ sources are compiled with -fno-exceptions support by default, for compatibility with previous versions.
To enable it, use the C ++ compiler flag '-fexceptions'. This can be done by adding the following to each module definition in your Android.mk:
LOCAL_CPPFLAGS += -fexceptions
Simply put, add one line to your Application.mk, the configuration will be automatically applied to all your NDK project modules:
APP_CPPFLAGS += -fexceptions
sources/cxx-stl/gnu-libstdc++/README :
This directory contains headers and ready-made binaries for GNU libstdC ++ - v3 Standard implementation of the C ++ template library.
They are generated from toolbinding sources with the rebuild-all-prebuilt.sh script command in the build / tools section.
To use it, define APP_STL in gnustl_static in Application.mk. See Docs / CPLUSPLUS-SUPPORT.html for more details.
This implementation fully supports C ++ and RTTI exceptions.
But all attempts to use exceptions fail. An alternative NDK exists at http://www.crystax.net/android/ndk-r4.php . Using the hello-jni example from this NDK does not work. Alignment with NDK 5 works after creating Application.xml with
APP_STL := gnustl_static
Setting APP_STL to gnustl_static also automatically includes -frtti and -fexceptions . But he is dying the same horrible death as my own experiments.
I managed to get a minimal code example that crashes for me:
try { __android_log_write(ANDROID_LOG_DEBUG,"foobar","trhown!"); throw "Wrong object type."; } catch (char* b) { __android_log_write(ANDROID_LOG_DEBUG,"foobar","catched!"); }
CPLUSPLUS-SUPPORT.html I missing something or is this statement in README and CPLUSPLUS-SUPPORT.html just wrong?