c++macosclangmacports

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.


Solution

  • 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.