How to compile & install libc++ on Linux


You want to compile and install libc++ (sometimes also named libcxx), but CMake complains with this error message

CMake Error at cmake/Modules/MacroEnsureOutOfSourceBuild.cmake:7 (message):
libcxx requires an out of source build. Please create a separate</em>

build directory and run 'cmake /path/to/libcxx [options]' there.
Call Stack (most recent call first):
CMake Error at cmake/Modules/MacroEnsureOutOfSourceBuild.cmake:8 (message):
 In-source builds are not allowed.

CMake would overwrite the makefiles distributed with Compiler-RT.
 Please create a directory and run cmake from there, passing the path
 to this source directory as the last argument.
 This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
 Please delete them.
Call Stack (most recent call first):


Once you know what “out-of-source-build” means, it’s actually pretty easy: You must not execute cmake from the libcxx directory itself, you need to execute it from any parent directory – the build will take place there.

Just run this script in your favourite shell:

mkdir libc++
svn co libcxx
cmake libcxx

This creates the directory libc++ inside your current directory and downloads and compiles the latest libc++ SVN trunk inside it. Run sudo make install inside the libc++ directory (not inside libcxx!) to install it globally.