Reputation: 121
I have been trying to use Clang's address code sanitizer, but the linker will not have it. The linker may be "ld", though my CMAKE settings assure me that clang is the linker.
Added -fsanitize=address
to compiler and linker flags.
Error:
Undefined symbols for architecture x86_64: ___asan_after_dynamic_init ... ___asan_before_dynamic_init ... etc. ld: symbol(s) not found for architecture x86_64 <<<< **suspicious** clang: error: linker command failed with exit code 1 (use -v to see invocation)
cmake: 3.7.1
CMAKE_CXX_COMPILER = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (redirects to clang)
Upvotes: 12
Views: 6359
Reputation: 159
Solution from here
Pass the -fsanitize=address flag to the linker as well as the compiler.
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
Upvotes: 14