I'm attempting to convert an existing Android.mk based build to CMake and I'm having difficulty building CPP code with exceptions and rtti. The cpp build command generated contains -fno-exceptions and -fno-rtti by default. Adding them as ANDROID_CPP_FEATURES or as cppFlags only appends them to the build command after the default options and the build still fails.
I've searched quite a bit and aside from the few pages pertaining to CMake on Android, I get mostly old Android.mk results from the search.
There is nothing special in any of the CMakeLists.txt file, nothing that would add those options as I can tell.
None of the uncommented options below work.
build.gradle:
externalNativeBuild {
cmake {
arguments '-DANDROID_TOOLCHAIN=gcc',
'-DANDROID_PLATFORM=android-19',
// '-DANDROID_STL_FORCE_FEATURES=ON',
'-DANDROID_STL=gnustl_static'
//'-DANDROID_CPP_FEATURES=rtti'
//'-DANDROID_CPP_FEATURES=exceptions',
cppFlags "-fexceptions -frtti"
targets 'library2'
}
}
Options in build command:
<removed content> -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -frtti -fexceptions -frtti -O2 -DNDEBUG -fPIC -MD -MT <additional content>
With the NDK toolchain r13b I'm using this combination in gradle. The part that through me off was that repeating -DANDROID_CPP_FEATURES overwrites itself and you need a space not a comma between exceptions and rtti.
externalNativeBuild {
cmake {
cppFlags '-std=c++11'
arguments '-DANDROID_TOOLCHAIN=clang',
'-DANDROID_PLATFORM=android-19',
'-DANDROID_STL=gnustl_static',
'-DANDROID_ARM_NEON=TRUE',
'-DANDROID_CPP_FEATURES=exceptions rtti'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With