In the Application.mk file, when using APP_STL := stlport_static i can use c++11 dynamic_cast but it won't compile the "random" features.
I've tried APP_STL := gnustl_static and APP_STL := c++_static but those won't let me use dynamic_cast.
What are the Application.mk proper settings to be able to use both at the same time?
My current Application.mk looks like:
APP_CPPFLAGS += -std=c++11
APP_STL := stlport_static
APP_ABI := armeabi armeabi-v7a x86
EDIT:
Following Michaels instructions finally the Application.mk that worked was:
#LIBCXX rebuild was needed once when using APP_STL := c++_static
LIBCXX_FORCE_REBUILD := true
APP_CPPFLAGS += -std=c++11 -frtti -fexceptions
APP_STL := c++_static
#Also the gnu compiler can be used
#APP_STL:= gnustl_static
APP_ABI := armeabi armeabi-v7a x86
NDK_TOOLCHAIN_VERSION := 4.8
Sounds like you forgot to enable RTTI, which dynamic_cast
uses to perform run-time type checks.
Quoting from the documentation:
[To] ensure compatibility with earlier releases, [the NDK toolchain] compiles all C++ sources with
-fno-rtti
by default.To enable RTTI support for your entire app for your entire application, add the following line to your Application.mk file:
APP_CPPFLAGS += -frtti
I don't see any random
header among the stlport sources, so it probably doesn't support that feature. Use another STL implementation instead, like gnustl.
So what you need is something like:
APP_CPPFLAGS += -std=c++11 -frtti
APP_STL := gnustl_static