【问题标题】:Building Boost Library for Android on OS X Mavericks在 OS X Mavericks 上为 Android 构建 Boost 库
【发布时间】:2014-10-13 22:00:48
【问题描述】:

我在尝试为 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.

【问题讨论】:

    标签: android gcc boost


    【解决方案1】:

    在使用 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-02
      • 2014-05-10
      • 2011-01-13
      • 2010-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多