我一直在尝试使用Clang的地址代码清理器,但是链接器将没有它。链接器可能是“ld”,尽管我的CMAKE设置可以确保clang是链接器。
在编译器和链接器标志中添加了-fsanitize=address
。
错误:
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)
环境:MacOS clang:Apple LLVM版本8.0.0(clang-800.0.38) cmake:3.7.1 CMAKE_CXX_COMPILER = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c ++(重定向到clang) CMAKE_CXX_COMPILER_ID = lang 编译器标志:-O0 -g -fsanitize =地址 CMAKE_LINKER = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c ++(重定向到clang) CMAKE_CXX_LINK_EXECUTABLE = CMAKE_CXX_COMPILER标志CMAKE_CXX_LINK_FLAGS LINK_FLAGS对象-o目标LINK_LIBRARIES CMAKE_CXX_LINK_FLAGS = -Wl,-search_paths_first -Wl,-headerpad_max_install_names -fsanitize = address -v here的解决方案
将-fsanitize = address标志传递给链接器以及编译器。
-DCMAKE_EXE_LINKER_FLAGS =“-fsanitize = address”