rdo
rdo

Reputation: 3982

How to install 'clang++' on OS X

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

Also I've installed clang with help of this specification. After installation, I've gotten additional a binary utility clang-3.5. But clang++-3.5 was not installed.

How can I install it?

Upvotes: 7

Views: 40488

Answers (2)

Timmmm
Timmmm

Reputation: 97118

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

Upvotes: 16

bazzargh
bazzargh

Reputation: 1852

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)

Upvotes: 9

Related Questions