简体   繁体   中英

How to Use AddressSanitizer on Android NDK GCC?

I want use AddressSanitizer to check memory problems in Android Native C++ Code compile with GCC 4.9.

so, I set

SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}  -g1 -fsanitize=address -fno-omit-frame-pointer")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g1 -fsanitize=address -fno-omit-frame-pointer")
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address -static-libasan")

in my CMakeLists.txt file.

but I got an error:

ld.exe: error: cannot find -lasan",i find in NDK directory,i do not find libasan.so

Is NDK GCC different from NDK Clang? in NDK,just Clan Support AddressSanitizer?

You can't use ASAN with GCC in the NDK. Those libraries were never shipped. ASAN is supported with Clang, and GCC is not supported at all in current NDKs.

Is NDK GCC different from NDK Clang?

In the same way that non-NDK GCC is different from non-NDK Clang, yes. They're different compilers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM