以下用 clang6.0 编译命令:
LDFLAGS="-L/usr/local/opt/myllvm6.0rc1/lib -fuse-ld=lld"
CPPFLAGS="-I/usr/local/opt/myllvm6.0rc1/include -I/usr/local/opt/myllvm6.0rc1/include/c++/v1/";
clang++ -fsanitize=address $LDFLAGS $CPPFLAGS -g -v main.cpp
给出:
"/usr/local/opt/myllvm6.0rc1/bin/ld64.lld" -demangle -lto_library /usr/local/opt/myllvm6.0rc1/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o a.out -L/usr/local/opt/myllvm6.0rc1/lib /var/folders/14/rc46ppds1ms2kj_mvdcxlc040000gn/T/main-113675.o -lc++ /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib -rpath @executable_path -rpath /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin -lSystem /usr/local/opt/myllvm6.0rc1/lib/clang/6.0.0/lib/darwin/libclang_rt.osx.a
warning: ignoring unknown argument: -no_deduplicate
warning: -sdk_version is required when emitting min version load command. Setting sdk version to match provided min version
Unable to find library for -lto_library
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
我不明白为什么它不能加载/usr/local/opt/myllvm6.0rc1/lib/libLTO.dylib
(它存在于这个位置!)任何想法?