iseale
iseale

Reputation: 121

MacOS - clang address sanitizer fails to link

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)

Upvotes: 12

Views: 6359

Answers (1)

Yunkang YU
Yunkang YU

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

Related Questions