"Thread" Boost 无法在 OSX 上构建?



我正在尝试从 OSX 10.10.5 上的源代码编译 boost 1.57,但似乎无法构建"线程"库。

OSX 10.10.5 优胜美地

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...

你认为问题出在哪里?

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

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

最新更新