"螺纹" Boost无法在OSX上构建?

时间:2016-01-29 00:02:05

标签: c++ macos boost

我试图在OSX 10.10.5上从源代码编译boost 1.57,但似乎无法构建" thread"库。

OSX 10.10.5 Yosemite

Xcode 6.1

这里是编译命令"

$ ./b2 toolset=clang cxxflags="-arch x86_64 -std=c++11 -stdlib=libstdc++ -ftemplate-depth=512" linkflags="-stdlib=libstdc++" link=static install --with-program_options --with-system --with-filesystem --with-chrono --with-thread

错误:

clang-darwin.compile.c++ bin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi/pthread/thread.o
In file included from libs/thread/src/pthread/thread.cpp:11:
In file included from ./boost/thread/thread_only.hpp:17:
In file included from ./boost/thread/pthread/thread_data.hpp:11:
In file included from ./boost/thread/lock_guard.hpp:12:
./boost/thread/detail/move.hpp:31:10: fatal error: 'type_traits' file not found
#include <type_traits>
         ^
1 error generated.

    "clang++" -x c++ -Wextra -Wno-long-long -Wno-variadic-macros -Wunused-function -arch x86_64 -std=c++11 -stdlib=libstdc++ -ftemplate-depth=512 -O3 -O3 -finline-functions -Wno-inline -Wall -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi/pthread/thread.o" "libs/thread/src/pthread/thread.cpp"

...failed clang-darwin.compile.c++ bin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi/pthread/thread.o...
clang-darwin.compile.c++ bin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi/pthread/once.o
In file included from libs/thread/src/pthread/once.cpp:8:
In file included from libs/thread/src/pthread/./once_atomic.cpp:9:
In file included from ./boost/thread/once.hpp:20:
In file included from ./boost/thread/pthread/once_atomic.hpp:16:
./boost/thread/detail/move.hpp:31:10: fatal error: 'type_traits' file not found
#include <type_traits>
         ^
1 error generated.

    "clang++" -x c++ -Wextra -Wno-long-long -Wno-variadic-macros -Wunused-function -arch x86_64 -std=c++11 -stdlib=libstdc++ -ftemplate-depth=512 -O3 -O3 -finline-functions -Wno-inline -Wall -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_BUILD_LIB=1 -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_THREAD_POSIX -DNDEBUG -I"." -c -o "bin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi/pthread/once.o" "libs/thread/src/pthread/once.cpp"

...failed clang-darwin.compile.c++ bin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi/pthread/once.o...
...skipped <pbin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi>libboost_thread.a(clean) for lack of <pbin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi>pthread/thread.o...
...skipped <pbin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi>libboost_thread.a for lack of <pbin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi>pthread/thread.o...
...skipped <p/usr/local/lib>libboost_thread.a for lack of <pbin.v2/libs/thread/build/clang-darwin-4.2.1/release/link-static/threading-multi>libboost_thread.a...
...failed updating 2 targets...
...skipped 3 targets...

您认为这是什么问题?

1 个答案:

答案 0 :(得分:0)

我是派对的后来者,但我遇到了同样的问题,问题是你想用C ++ 11构建它,而不是用libc ++构建它。

看起来旧版本的C ++ 11实现不完整。 libstdc ++缺少type_traits标头,就这么简单。使用-stdlib = libc ++开关,您应该进行排序。