3 c macos llvm clang llvm-clang
安装LLVMbrew install llvm
编辑.zshrc
...\nexport PATH="/usr/local/opt/llvm/bin:$PATH"\nexport LDFLAGS="-L/usr/local/opt/llvm/lib"\nexport CPPFLAGS="-I/usr/local/opt/llvm/include"\n...\nhello.c#include <stdio.h>\nint main()\n{\n    printf("Hello, World!");\n    return 0;\n}\nclang -v hello.c,我得到:clang version 8.0.1 (tags/RELEASE_801/final)\nTarget: x86_64-apple-darwin18.7.0\nThread model: posix\nInstalledDir: /usr/local/opt/llvm/bin\n "/usr/local/Cellar/llvm/8.0.1/bin/clang-8" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 450.3 -v -resource-dir /usr/local/Cellar/llvm/8.0.1/lib/clang/8.0.1 -fdebug-compilation-dir /Users/jdriwer/Projects -ferror-limit 19 -fmessage-length 212 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/qg/47c_70qn4wd9tlp18280f7k00000gn/T/hello-4a50cb.o -x c hello.c\nclang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-apple-darwin18.7.0\nignoring nonexistent directory "/usr/include"\n#include "..." search starts here:\n#include <...> search starts here:\n /usr/local/include\n /usr/local/Cellar/llvm/8.0.1/lib/clang/8.0.1/include\n /System/Library/Frameworks (framework directory)\n /Library/Frameworks (framework directory)\nEnd of search list.\nhello.c:1:10: fatal error: \'stdio.h\' file not found\n#include <stdio.h>\n         ^~~~~~~~~\n1 error generated.\n附言。llvm 的stdio.h位置:/usr/local/Cellar/llvm/8.0.1/include/c++/v1/stdio.h\n并且/usr/local/opt/llvm \xe2\x87\x92 ../Cellar/llvm/8.0.1是符号链接
有什么麻烦吗?
\n如果使用外部 LLVM 安装,请将这些添加到您的~/.bash_profile
LLVM_PATH="/usr/local/opt/llvm/" # or any other path
LLVM_VERSION="11.0.0"
export PATH="$LLVM_PATH:$PATH"
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export LD_LIBRARY_PATH="$LLVM_PATH/lib/:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="$LLVM_PATH/lib/:$DYLD_LIBRARY_PATH"
export CPATH="$LLVM_PATH/lib/clang/$LLVM_VERSION/include/"
export LDFLAGS="-L$LLVM_PATH/lib"
export CPPFLAGS="-I$LLVM_PATH/include"
export CC="$LLVM_PATH/bin/clang"
export CXX="$LLVM_PATH/bin/clang++"
(调整clang版本和外部llvm安装路径。)
然后运行source ~/.bash_profile
| 归档时间: | 
 | 
| 查看次数: | 5733 次 | 
| 最近记录: |