小编ise*_*ale的帖子

MacOS - clang 地址清理程序无法链接

我一直在尝试使用 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)
Run Code Online (Sandbox Code Playgroud)
  • 环境: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 = Clang
  • 编译器标志:-O0 -g -fsanitize=address
  • 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 …

macos cmake clang linker-errors address-sanitizer

6
推荐指数
1
解决办法
2333
查看次数

标签 统计

address-sanitizer ×1

clang ×1

cmake ×1

linker-errors ×1

macos ×1