How to install clang++ on osx?

给你一囗甜甜゛ 提交于 2019-12-10 21:24:33

问题


I've have got a default clang and clang++ in /usr/bin/ directory. Both of them have 3.3 version.

Also I've installed clang with help of this specification. After installation I've gotten additional binary utility clang-3.5. But clang++-3.5 was not installed. How to install it?


回答1:


I suspect all you were missing was libstdc++ but trying to figure that out without seeing your build log is impossible. Especially as you say 'after installation...' when there's no installation step in the instructions you link to, only build?

So, I'm going to suggest you use brew to do the install along with the dependencies. llvm35 is a bit bleeding edge but the current instructions that install that with brew are:

Step 1: make sure you have a recent enough gcc/libc to build clang (may not be necessary for you):

$ brew install gcc47 

Step 2: install the HEAD version of llvm35 with all the trimmings (see https://github.com/Homebrew/homebrew-versions/issues/340 - you MUST read this, because we are building HEAD versions the instructions might be updated tomorrow. Correct just now, I just built it!):

$ brew install isl --HEAD
$ brew install --cc=gcc-4.7 --HEAD llvm35 --with-asan --with-clang --with-libcxx --rtti --all-targets
# wait....
🍺  /usr/local/Cellar/llvm35/HEAD: 1427 files, 240M, built in 18.3 minutes

$ /usr/local/Cellar/llvm35/HEAD/bin/clang++-3.5 -v
clang version 3.5 
Target: x86_64-apple-darwin12.5.0
Thread model: posix

Note my command differs from the one in the link by including --cc=gcc-4.7 to use the gcc installed in step 1; if your gcc is already good enough, you won't need that. This is installed keg-only so won't be in the usual paths (see: https://github.com/Homebrew/homebrew/wiki/FAQ, by 'Cellar' they mean /usr/local/Cellar; I've shown the path mine built above)




回答2:


As of now you can just do

brew install llvm

For me this installed llvm and clang 4.0.0 to /usr/local/opt/llvm



来源:https://stackoverflow.com/questions/22004399/how-to-install-clang-on-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!