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

冷暖自知 提交于 2019-11-26 06:18:40

问题


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++?


回答1:


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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!