How to build boost 1.69.0 for Android with NDK r18

2019-08-20 05:56发布

问题:

I tried to use https://github.com/moritz-wundke/Boost-for-Android to compile boost for Android. It reports 1.69.0 is supported for NDK r18b. I'm under Windows 7.

I encountered many problems, some of them I could fix, but finally I could not get anything compiled:

  • Installed MinGW
  • Installed MySYS
  • Added MySYS to PATH
  • Ran build-android.bat
  • Got error: <path to NDK r18b> is not a valid NDK root -> Thats because the script checks if ndk-build exists -> Replaced "ndk-build" by "ndk-build.cmd" in script
  • Then I got error: sed: invalid option --E -> Removed -E option from sed at line 241
  • Note that I see a lot of non-blocking warnings expr: warning: unportable BRE:
  • Then I got the error: Undefined or not supported Android NDK version: Pkg.Revision = 18.1.5063045 (most likely due to this -E option I just removed) -> Replaced "16.0"|....|"18.1") by *) and removed *) original statement at lines 301/307
  • Then it reported curl was missing, I installed curl and added it to my path
  • Finally boost 1.69.0 download started
  • Then, I got tones of errors and nothing got built:
C:/dev/boost/Boost-for-Android-master/boost_1_69_0/tools/build/src/tools\common.
jam:979: in toolset-tag
*** argument error
* rule numbers.less ( n1 n2 )
* called with: ( 3 )
* missing argument n2 C:/dev/boost/Boost-for-Android-master/boost_1_69_0/tools/build/src/util\numbers.
jam:66:see definition of rule 'numbers.less' being called

and:

am:305: Unescaped special character in argument
<compileflags>$(AndroidNDKRoot)/
toolchains/x86_64-4.9/prebuilt/${PlatformOS}-x86_64 Performing
configuration checks

and finally:

ERROR: Failed to build boost for android for x86_64!

Any idea what I am doing wrong?


Edit: According to https://github.com/moritz-wundke/Boost-for-Android/issues/156, there is a problem with boost 1.69.0. So I tried with 1.68.0, then I get different errors:

C:\dev\boost\Boost-for-Android-master\boost_1_68_0\tools/build/src\user-config.j
am:70: Unescaped special character in argument <compileflags>$(AndroidNDKRoot)/t
oolchains/aarch64-linux-android-4.9/prebuilt/${PlatformOS}-x86_64

and

error: No best alternative for libs/context/build/asm_sources
    next alternative: required properties: <abi>aapcs <address-model>32 <architecture>arm <binary-format>elf <threading>multi <toolset>clang
...
    next alternative: required properties: <abi>sysv <architecture>combined <binary-format>mach-o <threading>multi
    not matched

and finally

clang-linux.archive ..\build\build\arm64-v8a\boost\bin.v2\libs\atomic\build\clan
g-linux-arm64v8a\release\link-static\target-os-android\threading-multi\libboost_
atomic-clang-mt-a64-1_68.a
'"ranlib"' n'est pas reconnu en tant que commande interne
ou externe, un programme ex'cutable ou un fichier de commandes.

    "c:/Android2/android-ndk-r18b/toolchains/llvm/prebuilt/windows-x86_64/bin/ll
vm-ar"  rc "..\build\build\arm64-v8a\boost\bin.v2\libs\atomic\build\clang-linux-
arm64v8a\release\link-static\target-os-android\threading-multi\libboost_atomic-c
lang-mt-a64-1_68.a" "..\build\build\arm64-v8a\boost\bin.v2\libs\atomic\build\cla
ng-linux-arm64v8a\release\link-static\target-os-android\threading-multi\lockpool
.o"
    "ranlib" "..\build\build\arm64-v8a\boost\bin.v2\libs\atomic\build\clang-linu
x-arm64v8a\release\link-static\target-os-android\threading-multi\libboost_atomic
-clang-mt-a64-1_68.a"

...failed clang-linux.archive ..\build\build\arm64-v8a\boost\bin.v2\libs\atomic\
build\clang-linux-arm64v8a\release\link-static\target-os-android\threading-multi
\libboost_atomic-clang-mt-a64-1_68.a...
...removing ..\build\build\arm64-v8a\boost\bin.v2\libs\atomic\build\clang-linux-
arm64v8a\release\link-static\target-os-android\threading-multi\libboost_atomic-c
lang-mt-a64-1_68.a