在 Windows 下,Android 的 boost 编译失败

Posted

技术标签:

【中文标题】在 Windows 下,Android 的 boost 编译失败【英文标题】:boost compile for Android fails under windows 【发布时间】:2016-07-17 10:42:39 【问题描述】:

我正在尝试使用 Cygwin 和/或 cmd 在 Windows 下为 android 编译一些 Boost 库。

我按照此处显示的说明进行操作:http://www.boost.org/doc/libs/1_61_0/more/getting_started/windows.html

在我设置好必要的环境变量之后:

//At first I tried with cmd
set NDK_ROOT=C:\android-ndk-r12b
set TOOLCHAIN_PATH=C:\android-ndk-r12b\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64
set PATH=%PATH%;C:\boost_build\bin;%TOOLCHAIN_PATH%\bin
set NO_BZIP2=1

//I also tried with cygwin
TOOLCHAIN_PATH=/cygdrive/c/android-ndk-r12b/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/
NDK_ROOT=/cygdrive/c/android-ndk-r12b/
PATH=$PATH:/cygdrive/c/boost_build/bin:/cygdrive/c/android-ndk-r12b/:$TOOLCHAIN_PATH/bin
NO_BZIP2=1

现在我正在使用这些参数启动 b2:

b2 --build-dir=C:\boost_builded toolset=gcc link=static threading=multi --with-system --with-date_time --with-random stage

我收到这些错误:

//The errors are the same both in cmd and in cygwin
...patience...
...found 1014 targets...
...updating 18 targets...
gcc.archive C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_date_time-gcc54-mt-d-1_61.a
The system cannot find the path specified.
The system cannot find the path specified.

    "\usr\i686-pc-cygwin\bin\ar.exe"  rc "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_date_time-gcc54-mt-d-1_61.a" "C:\boost_builded\boost\b
in.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\gregorian\greg_month.o" "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\gregorian
\greg_weekday.o" "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\gregorian\date_generators.o"
    "\usr\i686-pc-cygwin\bin\ranlib.exe" "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_date_time-gcc54-mt-d-1_61.a"

...failed gcc.archive C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_date_time-gcc54-mt-d-1_61.a...
...skipped <pstage\lib>libboost_date_time-gcc54-mt-d-1_61.a for lack of <pC:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\debug\link-static\threading-multi>libboost_date_time-gcc54-mt-d-1
_61.a...
gcc.archive C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_system-gcc54-mt-d-1_61.a
The system cannot find the path specified.
The system cannot find the path specified.

    "\usr\i686-pc-cygwin\bin\ar.exe"  rc "C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_system-gcc54-mt-d-1_61.a" "C:\boost_builded\boost\bin.v2\
libs\system\build\gcc-5.4.0\debug\link-static\threading-multi\error_code.o"
    "\usr\i686-pc-cygwin\bin\ranlib.exe" "C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_system-gcc54-mt-d-1_61.a"

...failed gcc.archive C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_system-gcc54-mt-d-1_61.a...
...skipped <pstage\lib>libboost_system-gcc54-mt-d-1_61.a for lack of <pC:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\debug\link-static\threading-multi>libboost_system-gcc54-mt-d-1_61.a...
gcc.archive C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_random-gcc54-mt-d-1_61.a
The system cannot find the path specified.
The system cannot find the path specified.

    "\usr\i686-pc-cygwin\bin\ar.exe"  rc "C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_random-gcc54-mt-d-1_61.a" "C:\boost_builded\boost\bin.v2\
libs\random\build\gcc-5.4.0\debug\link-static\threading-multi\random_device.o"
    "\usr\i686-pc-cygwin\bin\ranlib.exe" "C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_random-gcc54-mt-d-1_61.a"

...failed gcc.archive C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\debug\link-static\threading-multi\libboost_random-gcc54-mt-d-1_61.a...
...skipped <pstage\lib>libboost_random-gcc54-mt-d-1_61.a for lack of <pC:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\debug\link-static\threading-multi>libboost_random-gcc54-mt-d-1_61.a...
gcc.archive C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\libboost_date_time-gcc54-mt-1_61.a
The system cannot find the path specified.
The system cannot find the path specified.

    "\usr\i686-pc-cygwin\bin\ar.exe"  rc "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\libboost_date_time-gcc54-mt-1_61.a" "C:\boost_builded\boost\b
in.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\gregorian\greg_month.o" "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\grego
rian\greg_weekday.o" "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\gregorian\date_generators.o"
    "\usr\i686-pc-cygwin\bin\ranlib.exe" "C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\libboost_date_time-gcc54-mt-1_61.a"

...failed gcc.archive C:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi\libboost_date_time-gcc54-mt-1_61.a...
...skipped <pstage\lib>libboost_date_time-gcc54-mt-1_61.a for lack of <pC:\boost_builded\boost\bin.v2\libs\date_time\build\gcc-5.4.0\release\link-static\threading-multi>libboost_date_time-gcc54-mt-1_6
1.a...
gcc.archive C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\release\link-static\threading-multi\libboost_system-gcc54-mt-1_61.a
The system cannot find the path specified.
The system cannot find the path specified.

    "\usr\i686-pc-cygwin\bin\ar.exe"  rc "C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\release\link-static\threading-multi\libboost_system-gcc54-mt-1_61.a" "C:\boost_builded\boost\bin.v2\
libs\system\build\gcc-5.4.0\release\link-static\threading-multi\error_code.o"
    "\usr\i686-pc-cygwin\bin\ranlib.exe" "C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\release\link-static\threading-multi\libboost_system-gcc54-mt-1_61.a"

...failed gcc.archive C:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\release\link-static\threading-multi\libboost_system-gcc54-mt-1_61.a...
...skipped <pstage\lib>libboost_system-gcc54-mt-1_61.a for lack of <pC:\boost_builded\boost\bin.v2\libs\system\build\gcc-5.4.0\release\link-static\threading-multi>libboost_system-gcc54-mt-1_61.a...
gcc.archive C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\release\link-static\threading-multi\libboost_random-gcc54-mt-1_61.a
The system cannot find the path specified.
The system cannot find the path specified.

    "\usr\i686-pc-cygwin\bin\ar.exe"  rc "C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\release\link-static\threading-multi\libboost_random-gcc54-mt-1_61.a" "C:\boost_builded\boost\bin.v2\
libs\random\build\gcc-5.4.0\release\link-static\threading-multi\random_device.o"
    "\usr\i686-pc-cygwin\bin\ranlib.exe" "C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\release\link-static\threading-multi\libboost_random-gcc54-mt-1_61.a"

...failed gcc.archive C:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\release\link-static\threading-multi\libboost_random-gcc54-mt-1_61.a...
...skipped <pstage\lib>libboost_random-gcc54-mt-1_61.a for lack of <pC:\boost_builded\boost\bin.v2\libs\random\build\gcc-5.4.0\release\link-static\threading-multi>libboost_random-gcc54-mt-1_61.a...
...failed updating 6 targets...
...skipped 6 targets...
...updated 6 targets...

我什至不确定他没有找到什么路径。我认为它正在寻找“\usr\i686-pc-cygwin\bin\ar.exe”,因为其他路径似乎正确且存在;但我认为它正在寻找“\”,就好像它是linux系统的根目录,而不是在cygwin的子目录中。

如何改正?

【问题讨论】:

Cygwin 有自己的根目录。您可以在路径上使用ls,看看那里有什么。 【参考方案1】:

....一如既往,对我来说,在 *** 上发帖是一种宣泄。在把我的头撞到墙上几个小时后,我在这里发布了问题,然后我在 5 分钟内找到了解决方案。

我将把解决方案留在这里,以防将来对其他人有用。

我的猜测是正确的。他在错误的地方寻找\usr\i686-pc-cygwin\bin\ar.exe。所以我从根目录C:\usr\i686-pc-cygwin中的cygwin根C:\cygwin\usr\i686-pc-cygwin\复制了文件夹。它奏效了。

可能是一个 b2 错误,我会尝试发出信号。

【讨论】:

以上是关于在 Windows 下,Android 的 boost 编译失败的主要内容,如果未能解决你的问题,请参考以下文章

在 Windows 下,Android 的 boost 编译失败

如何在win 环境下进行Android CTS 测试

在Windows下搭建Android开发环境

第19章 Windows10系统下QT搭建Android开发环境

Android Studio在Windows系统下的安装教程艺术鉴赏课

windows下eclipse搭建android_ndk开发环境