Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install clang++ on osx?

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?

like image 751
rdo Avatar asked Feb 25 '14 04:02

rdo


People also ask

Does macOS have Clang?

From Xcode 4.2, Clang is the default compiler for Mac OS X.

Does Mac use Clang or GCC?

Apple ships the clang/LLVM compiler with macOS. Clang is a "front-end" that can parse C , C++ and Objective-C down to something that LLVM (referred to as a "back-end") can compile. Clang/LLVM is located in /Applications/Xcode. app/somewhere.


Video Answer


2 Answers

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)

like image 196
bazzargh Avatar answered Oct 04 '22 14:10

bazzargh


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

like image 29
Timmmm Avatar answered Oct 04 '22 15:10

Timmmm