Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

The answer to this question Why can't clang with libc++ in c++0x mode link this boost::program_options example? 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++?

like image 603
x-x Avatar asked Dec 13 '11 08:12

x-x


People also ask

Does boost need to be compiled?

Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking. The only Boost libraries that must be built separately are: Boost.

Does C++ use libc?

Most implementations of libstdc++ depend on libc, so they require it. The C++ standard includes most of the C standard library. So it's kind of a dependency and technically it's part of the C++ standard library.

Is libc installed?

Here's how to check if a library is installed: Type ldconfig -p | grep libc++ into the terminal. It does not matter what system you are using. If libc++ is not installed, the terminal will not say anything.


1 Answers

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.

like image 132
Howard Hinnant Avatar answered Oct 10 '22 03:10

Howard Hinnant