Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install clang 3.1 using macports? (OSX, snow leopard)

I'd like to install the latest clang (3.1) compiler using macports (I use emacs rather than xcode, and the version of clang that comes with xcode is older anyway). macports seems to have the latest versions of gcc, but when I enter "port list clang" the only version that shows up is 2.9. I use the C++11 features, so I want to use the latest version.

I'm running snow leopard on an MBP.

like image 390
daj Avatar asked Apr 29 '12 00:04

daj


2 Answers

Clang has several different versions available on MacPorts:

$ port search clang

clang @2.9 (lang)
    C, C++, Objective C and Objective C++ compiler

clang-2.9 @2.9 (lang)
    C, C++, Objective C and Objective C++ compiler

clang-3.0 @3.0 (lang)
    C, C++, Objective C and Objective C++ compiler

clang-3.1 @3.1-r154872 (lang)
    C, C++, Objective C and Objective C++ compiler

clang-devel @3.0 (lang)
    C, C++, Objective C and Objective C++ compiler

clang_select @0.1 (sysutils)
    common files for selecting default clang version

Found 6 ports.

So if you just install the clang port, it'll install version 2.9. If you want 3.1, install the clang-3.1 port. You can also install clang_select, which is a utility that allows you to easily switch between multiple installations of Clang; without it, you have to manually specify the version of the Clang binary you want each time.

like image 160
Adam Rosenfield Avatar answered Sep 21 '22 10:09

Adam Rosenfield


Just specify the version number: port list clang-3.1

Worked fine for me. I'm on Lion, but I don't see why that would make a difference.

like image 31
jalf Avatar answered Sep 20 '22 10:09

jalf