C++ 如何使用 clang++/libc++ 编译/链接 Boost?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8486077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to compile/link Boost with clang++/libc++?
提问by x-x
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++."
这个问题的答案Why can't clang with libc++ in c++0x mode link this boost::program_options example?声明“您需要使用 clang++ -stdlib=libc++ 重建 boost。”
I'm using MacOS Lion with clang v3.0. How do I build Boost v1.48.0 using clang and link it with libc++?
我正在使用 MacOS Lion 和 clang v3.0。如何使用 clang 构建 Boost v1.48.0 并将其与 libc++ 链接?
Update: I've created a user-config.jamfile with the following:
更新:我创建了一个user-config.jam文件,内容如下:
using clang-darwin
...which will build Boost with clang instead of gcc. How do I link with libc++ instead of libstdc++?
...这将使用 clang 而不是 gcc 构建 Boost。如何链接 libc++ 而不是 libstdc++?
回答by Howard Hinnant
I didn't know how to do this either. But after poking around in here, the getting started, and trialand 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 thinkit works.
你会收到很多警告。由于LWG 2059,信号库将无法构建。但除此之外,我认为它有效。