How to compile/link Boost with clang++/libc++?

C++BoostClangLibc++

C++ Problem Overview


The answer to this question https://stackoverflow.com/q/8454329/331024 states "You need to rebuild boost using clang++ -stdlib=libc++."

I'm using MacOS Lion with clang v3.0. How do I build Boost v1.48.0 using clang and link it with libc++?

Update: I've created a user-config.jam file with the following:

using clang-darwin

...which will build Boost with clang instead of gcc. How do I link with libc++ instead of libstdc++?

C++ Solutions


Solution 1 - C++

I didn't know how to do this either. But after poking around in here, the getting started, and trial and error:

$ ./bootstrap --with-toolset=clang
$ ./b2 clean
$ ./b2 toolset=clang cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++"

You'll get lots of warnings. And the signals library will fail to build due to LWG 2059. But otherwise I think it works.

Solution 2 - C++

Another option is to use Homebrew:

brew install boost --c++11

To get information on all options use:

brew info boost

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionx-xView Question on Stackoverflow
Solution 1 - C++Howard HinnantView Answer on Stackoverflow
Solution 2 - C++Jonas KView Answer on Stackoverflow