mrgloom mrgloom - 1 month ago 15
C++ Question

How to use AddressSanitizer in gcc?

I'm trying to build my project with

g++ -O0 -g -fsanitize=address -fno-omit-frame-pointer


but get lots of errors like:

/home/user/libs/opencv/include/opencv2/core/mat.hpp:715: undefined reference to `__asan_report_load8'


How to compile project with AddressSanitize support?

gcc -v


gcc version 4.8.4

Answer

You need to add the switch -lasan to your compile/link command line to link the correct library.