在OS X Mavericks上为Android构建Boost库

时间:2014-10-13 22:00:48

标签: android gcc boost

我在尝试为Android构建boost库时遇到问题。我安装了苹果命令行工具,我下载了boost。我一直收到这个错误:

In file included from libs/thread/src/pthread/thread.cpp:9:
In file included from ./boost/thread/detail/config.hpp:11:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
./boost/config/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
#     include <unistd.h>
              ^
1 error generated.
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/thread.o...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/once.o

    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -Wno-unused-function --sysroot=/Users/mac/src/android/tc/sysroot   -fPIC -O3 -Wextra -Wno-long-long -Wno-variadic-macros -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_STATIC_LINK=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/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/once.o" "libs/thread/src/pthread/once.cpp"

In file included from libs/thread/src/pthread/once.cpp:6:
In file included from ./boost/thread/detail/config.hpp:11:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
./boost/config/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
#     include <unistd.h>
              ^
1 error generated.
...failed gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/pthread/once.o...
gcc.compile.c++ bin.v2/libs/thread/build/gcc-android/release/link-static/runtime-link-static/threading-multi/future.o

    "g++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -pedantic -Wno-unused-function --sysroot=/Users/mac/src/android/tc/sysroot   -fPIC -O3 -Wextra -Wno-long-long -Wno-variadic-macros -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_ATOMIC_STATIC_LINK=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/gcc-android/release/link-static/runtime-link-static/threading-multi/future.o" "libs/thread/src/future.cpp"

In file included from libs/thread/src/future.cpp:6:
In file included from ./boost/thread/detail/config.hpp:11:
In file included from ./boost/config.hpp:57:
In file included from ./boost/config/platform/macos.hpp:28:
./boost/config/posix_features.hpp:18:15: fatal error: 'unistd.h' file not found
#     include <unistd.h>
              ^
1 error generated.

1 个答案:

答案 0 :(得分:0)

我在使用MacOSX10.7.sdk在Maverick上构建Boost 1.55.0时也是如此。所以我在编译命令中为cflags和cxxflags选项添加了-I/usr/include。它解决了这个问题。我完整的命令。

./b2 -d+2 toolset=clang cxxflags="-stdlib=libc++ -isysroot=$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -I/usr/include" cflags="-stdlib=libc++ -isysroot=$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET  -I/usr/include" --layout=system --build-type=minimal --prefix=$QTDIR link=static runtime-link=static variant=release install