Building libc++ on Linux

It would be very helpful if the web pages were updated to give instructions for installation of libc++ on Linux.

There is also no information in the source code itself. At least I could not find any.

There is some in past messages, including how to make cxxabi.h accessible for gcc 4.4 and 4.6.


Dr John P. Fletcher Tel: (44) 121 204 3389 (direct line), FAX: (44) 121 204 3678
Chemical Engineering and Applied Chemistry (CEAC),
formerly Associate Dean - External Relations,
School of Engineering and Applied Science (EAS),
Aston University, Aston Triangle, BIRMINGHAM B4 7ET U.K.

Yea, That will be greatly appreciated.
One time, I was planning to build libc++ on linux, But of no use.


Building libc++ on any platform is not a task for the faint hearted...

It involves making several decisions:

- Which ABI library are you going to choose. The current options are:

  - libsupc++, which is the most mature but is covered by the same license as GNU libstdc++

  - libcxxrt, which is BSD licensed and has been used in production on Linux, NetBSD, FreeBSD and Solaris (and is now imported into the FreeBSD tree as a libsupc++ replacement), but is still newer than libsupc++.

  - libc++abi, which is part of LLVM but is the least mature of the lot

- Are you going to support linking libraries using libc++ with libraries linking libstdc++? If so, then you must either link libc++ to libstdc++ or link both libstdc++ and libc++ to the same ABI library. In FreeBSD, we link both to libcxxrt and compile libstdc++ as a filter library to allow for symbol versioning to continue to work and avoid breaking the ABI for programs that linked directly to libstdc++, which previously statically linked to libsupc++. If not, then you can simply link libc++ to whichever ABI library you choose.

- Are you going to make any of the ABI interfaces public? By default, libcxxrt does not install any of its headers because the ABI <-> STL interface is at least semiprivate, although libobjc2 depends on some parts of it (which are not supported by libc++abi, but are supported by libsupc++ and libcxxrt).

Actually building libc++ itself is pretty trivial - just compile all of the source files and link them. clang -std=c++0x -shared *.cpp -o is about all that's needed, although you will need to add -I flags for finding the headers for your ABI-library-of-choice and a -l flag for linking to it.

Building it, however, is the easy part. Deciding on how it will be installed and linked is much harder.


Add -DLIBCXXRT here if building against libcxxrt, otherwise you will run
into issues with cerr on Linux. No solution for libc++abi, I think.