I am trying to create a simple test app in Android Studio with C++ support. I also need to pass some extra linker flags to the native build. In the older Android.mk build format this was fairly simple and documented. However, Android Studio now defaults to using cmake for the native libraries, and its not clear how I can specify the extra linker flags to be passed to the NDK.
The specific flag I am trying to add is -fsanitize=address
in order to enable ASAN. I have been able to pass this flag to the compiler by adding it to the cppFlags property in CMake as follows.
Is there a similar way to pass in a linker flag in the gradle file?
externalNativeBuild {
cmake {
cppFlags "-std=c++11 -frtti -fexceptions -fsanitize=address"
}
}