Building libc++ on Mac OS X 10.6

2012 November 7

With perfect timing to trip me up, LLVM's C++ Standard Library project, libc++, just updated their build instructions after removing the special notes for building on Mac OS X 10.6. Since I don't have access to the latest OS X on my work computers, I rely on those old instructions. Understandably, Google does not index libc++'s Subversion repository browser, so those old instructions are effectively lost to search forever... unless I repost them here:

  1. Start in a safe place.

    $ mkdir libcxx
    $ cd libcxx
  2. Special for Mac OS X 10.6: LLVM's C++ Standard Library ABI, libc++abi, is not included with Snow Leopard. You must install it yourself.

    $ wget
    $ unzip
    $ sudo cp cxxabi.h /usr/include
    $ sudo cp libc++abi.dylib /usr/lib
  3. Check out.

    $ svn co source
  4. Build.

    $ cd source/lib
    $ export TRIPLE=-apple-
    $ export MACOSX_DEPLOYMENT_TARGET=10.6 # special for Mac OS X 10.6
    $ ./buildit
  5. Install.

    $ cd /usr/lib
    $ sudo ln -s path/to/libcxx/source/lib/libc++.1.dylib
    $ sudo ln -s libc++.1.dylib libc++.dylib
    $ cd /usr/include/c++
    $ sudo ln -s path/to/libcxx/source/include v1