1

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?

1
  • 1
    "just Clang Support AddressSanitizer?" Yes: "As a first step to building an ASan-instrumented binary, make sure that your code builds with Clang". GCC has been deprecated in the NDK for a while anyway, and was removed altogether in NDK r18. Commented Oct 23, 2018 at 8:25

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

i get NDK GCC 4.9 source code android.googlesource.com/toolchain/gcc/+/ndk-r16/gcc-4.9 , there has libsanitizer source code .so,if i comple libsanitizer by myself ,can i get a lasan.so used to support ASAN to NDK GCC?
Maybe, but why bother?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.