Boost logo

Boost :

Subject: Re: [boost] Going insane trying to build boost for android
From: Robert Dailey (rcdailey.lists_at_[hidden])
Date: 2017-03-26 15:59:17


On Thu, Mar 23, 2017 at 9:14 PM, Robert Dailey <rcdailey.lists_at_[hidden]> wrote:
> How many months has it been of lost google searching, trying to beat
> b2 into submission. I have no idea at this point how to build boost
> for Android. Really hoping I get some help here...
>
> So to start, here are the versions I'm using:
>
> - Android NDK r14b
> - Boost 1.63.0
>
> I'm doing all of this on Windows 10, through command prompt.
>
> I want to use clang and libc++ to build boost for API 15. I figure the
> easiest way is to generate a standalone toolchain using the NDK, so I
> did that first:
>
>> %ANDROID_NDK%\build\tools\make_standalone_toolchain.py --arch arm --api 15 --stl libc++ "C:\android\_toolchains\arm-api-15"
>
> This generated the appropriate toolchain (I think).
>
> I then temporarily added this location to PATH:
>
>> set PATH=C:\android\_toolchains\arm-api-15\bin;%PATH%
>
> Then I ran bootstrap:
>
>> bootstrap.bat --with-toolset=clang
>
> Then I tried to build boost itself:
>
>> b2 --toolset=clang cxxflags="-stdlib=libc++ -std=c++14" threadapi=pthread --prefix=..\boost_android_arm --builddir=./ target-os=linux define=BOOST_FILESYSTEM_VERSION=3 --without-python link=static runtime-link=shared threading=multi variant=release install -j8
>
> However I get failures when it tries to run the clang command:
>
> 'C:\code\_third_party\boost_1_63_0\\clang38++.exe' is not recognized
> as an internal or external command
>
> I'm not sure why it's appending that absolute path (that's where my
> current directory is set to, and where boost source is). It should
> just be trying to use "clang++" but doesn't look like it is.
>
> From the output, it looks like it's trying to use clang correctly I think:
>
> "clang++" -c -x c++ -stdlib=libc++ -std=c++14 -O3 -Wno-inline -Wall
> -pthread -stdlib=libc++ -std=c++14 -DBOOST_ALL_NO_LIB=1
> -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_THREAD_USE_LIB=1 -DNDEBUG -I"."
> -o "bin.v2\libs\wave\build\clang-linux-android\release\link-static\target-os-linux\threadapi-pthread\threading-multi\cpplexer\re2clex\aq.o"
> "libs\wave\src\cpplexer\re2clex\aq.cpp"
>
> Am I going about this all wrong? How in the heck can I build boost for
> android using the settings I specified above?

So I beat on this a bit more and I'm past the clang path issue (it was
some %~dp0/clang38++.exe stuff the batch file was doing which didn't
resolve the right base path)

What are the actual include directories I need to use for clang? I
think that's the difficulty I'm running into now... errors like:

clang-linux.compile.c++.without-pth
bin.v2\libs\atomic\build\clang-linux-android\release\link-static\target-os-android\threadapi-pthread\threading-multi\lockpool.o
In file included from libs\atomic\src\lockpool.cpp:16:
In file included from .\boost/config.hpp:57:
In file included from .\boost/config/platform/linux.hpp:15:
C:/android/ndk/sources/cxx-stl/llvm-libc++/include\cstdlib:108:9:
error: no member named 'strtold' in the global namespace
using ::strtold;
      ~~^

My config jam:

import common ;
import configure ;
import build-system ;
import generate ;
import modules ;
import option ;
import os ;
import package ;
import path ;
import project ;
import regex ;
import set ;
import targets ;
import feature ;
import property ;

local androidNDKRoot = C:/android/ndk ; # put the relevant path

using clang : android
    :
    $(androidNDKRoot)/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++
    :
    <compileflags>-std=c++14
    <compileflags>-stdlib=libc++
    <compileflags>--sysroot=$(androidNDKRoot)/platforms/android-15/arch-arm
    <compileflags>-I$(androidNDKRoot)/sources/android/support/include
    <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
    <compileflags>-I$(androidNDKRoot)/sources/cxx-stl/llvm-libc++/include
    <compileflags>-fno-strict-aliasing
    <compileflags>-D__GLIBC__
    <compileflags>-DANDROID
    <compileflags>-D__ANDROID__
    <compileflags>-D_GLIBCXX__PTHREADS
    <compileflags>-D__arm__
    <compileflags>-D_REENTRANT
    <compileflags>-O2
    <compileflags>-DNDEBUG
    ;

And I'm running this command:

b2 ^
    --user-config=clang-android.jam ^
    target-os=android ^
    toolset=clang-android ^
    threadapi=pthread ^
    link=static ^
    runtime-link=shared ^
    threading=multi ^
    variant=release ^
    --prefix=..\boost_android_arm ^
    --builddir=./ ^
    --without-python ^
    -j1 ^
    install


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk