NDK development, build.gradle
temporarily add a -fnoexception
compiler option:
externalNativeBuild {
cmake {
cppFlags '-std=c++11 -fexceptions' //!!!这里是新增的
arguments '-DANDROID_PLATFORM=android-21',
'-DCMAKE_BUILD_TYPE="Release',
'-DANDROID_ARM_NEON=ON',
'-DANDROID_STL=c++_shared'
// cppFlags '-std=c++11'
// arguments '-DANDROID_TOOLCHAIN=clang',
// '-DANDROID_STL=c++_static'
// cppFlags "-std=c++11 -fexceptions"
}
}
The results, click on the sync now
following, CMake scripts have lost highlighting and error prompt clang ++ can not identify -fnoexception. Inspection found CMake script is set in the CMAKE_CXX_FLAGS
value of which has -fno-exceptions
caused can be removed:
#SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions -fno-short-enums -Werror=non-virtual-dtor")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-short-enums -Werror=non-virtual-dtor")
That is build.gradle cmake scripts and script of the C ++ compiler options, whether to enable exception for the conflict caused.