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++?
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.
Another option is to use Homebrew:
brew install boost --c++11
To get information on all options use:
brew info boost
来源:https://stackoverflow.com/questions/8486077/how-to-compile-link-boost-with-clang-libc