I want to compile pref for android device and i did that base on the guide the guide. One i set NDK environment use Android NDK r9
export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-
export NDK_SYSROOT=${NDK}/platforms/android-9/arch-arm
I run make with tool
make ARCH=arm CROSS_COMPILE=${NDK_TOOLCHAIN} CFLAGS="--sysroot=${NDK_SYSROOT}"
I recieve the error, so can you help me?
Android NDK: NDK_TOOLCHAIN is defined to the unsupported value android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-
Android NDK: Please use one of the following values: arm-linux-androideabi-4.6 arm-linux-androideabi-4.8 arm-linux-androideabi-clang3.2 arm-linux-androideabi-clang3.3 mipsel-linux-android-4.6 mipsel-linux-android-4.8 mipsel-linux-android-clang3.2 mipsel-linux-android-clang3.3 x86-4.6 x86-4.8 x86-clang3.2 x86-clang3.3
build/core/init.mk:555: * Android NDK: Aborting . Stop.
Android bundles the simpleperf tool which is almost a drop-in replacement for many usages of perf/linux-tool-perf.
https://developer.android.com/ndk/guides/simpleperf
Have you looked at external/linux-tools-perf/ inside android repository?
https://android.googlesource.com/platform/external/linux-tools-perf/
the error clearly says , you need select appropriate value while exporting ,
export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-
should be
export NDK_TOOLCHAIN=${NDK}/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-4.6
If it dosen't work , i recommend you recheck the overall path which $NDK_TOOLCHAIN contains.
Thanks , Jain
Related
So while compiling android kernel for my 1plus phone, after multiples attempts over 3 days, I gave up and give a try to ask here if anyone had this problem before.
The bug is a bit obscure to me, but I feel like the problem comes from my recent change to a GNU/Linux distribution (Gentoo), which is somehow overriding the AS environment variable when it shouldn't; it fails at assembling VDSO, but I've no idea sadly from where the overriding comes. (maybe they did a modify the make command in order to allow supporting flags overriding etc..)
EDIT, Small version:
make RANLIB=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-ranlib CC='/media/sda2/git/linux-x86/clang-bootstrap/bin/clang -fintegrated-as' LD=/media/sda2/git/linux-x86/clang-bootstrap/bin/ld.lld AR=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-ar AS=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-as NM=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-nm OBJCOPY=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-objcopy OBJDUMP=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-objdump READELF=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-readelf OBJSIZE=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-size STRIP=/media/sda2/git/linux-x86/clang-bootstrap/bin/llvm-strip
CC kernel/bounds.s
CC arch/arm64/kernel/asm-offsets.s
In file included from arch/arm64/kernel/asm-offsets.c:25:
In file included from ./include/linux/kvm_host.h:39:
In file included from ./arch/arm64/include/asm/kvm_host.h:42:
In file included from ./include/kvm/arm_pmu.h:21:
In file included from ./include/linux/perf_event.h:57:
In file included from ./include/linux/cgroup.h:28:
./include/linux/cgroup-defs.h:475:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
CALL scripts/checksyscalls.sh
LDS arch/arm64/kernel/vdso/vdso.lds
VDSOA arch/arm64/kernel/vdso/gettimeofday.o
/usr/bin/as: unrecognized option '-EL'
clang-12: error: assembler command failed with exit code 1 (use -v to see invocation)
make[1]: *** [arch/arm64/kernel/vdso/Makefile:57: arch/arm64/kernel/vdso/gettimeofday.o] Error 1
make: *** [arch/arm64/Makefile:201: vdso_prepare] Error 2
Environment variables:
# https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
export PATH='/media/sda2/git/aarch64-linux-android-4.9/bin':${PATH}
export LD_LIBRARY_PATH='/media/sda2/git/aarch64-linux-android-4.9/lib':${LD_LIBRARY_PATH}
# git clone https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
export PATH='/media/sda2/git/linux-x86/clang-bootstrap/bin':${PATH}
export LD_LIBRARY_PATH='/media/sda2/git/linux-x86/clang-bootstrap/lib':${LD_LIBRARY_PATH}
export ARCH=arm64
export SUBARCH=arm64
export CROSS_COMPILE='aarch64-linux-android-'
export CROSS_COMPILER=$PATH
export CLANG_TRIPLE='aarch64-linux-gnu-'
export KCFLAGS='-pipe -O3'
export KCPPFLAGS='-pipe -O3'
Kernel used:
https://github.com/LineageOS/android_kernel_oneplus_sm8250
Any ideas?
I use Google's clang prebuilt compiler (could build it myself but in order to gain time) in order to use polly for compiling android kernels since Gentoo LLVM team doesn't apparently have yet a use flag for it.
At worse I'm thinking to use Ubuntu binutils/automake etc / creating a docker environment in order to compile this kernel but this just doesn't make many sense to me since I should be able to do it on my own host system.
Thank you for your help and your care.
I got it solved.
After removing LD=/media/sda2/git/linux-x86/clang-bootstrap/bin/ld.lld for the linker, it worked, I suppose the clang linker was using /usr/bin/as by default and not aarch64-linux-android-as which is google's prebuilt. I'll need to investigate about it further. I'll edit this post once I found more.
I have met the same problem.
The root cause is that the CLANG_PATH should add before the PATH.
// have chance to use /usr/bin/as
export PATH=$PATH:$CLANG_PATH // wrong
export PATH=${CLANG_PATH}:${PATH} // correct
IGNORE
set the cross-compile tool patch correctly
The reason is that you do not set the CROSS_COMPILE and the CROSS_COMPILE_ARM32 correctly.
The aarch64-linux-android-as can not find in PATH. So it uses /usr/bin/as.
You should put the cross compile tools into patch or just set the absolute patch like this:
export CROSS_COMPILE=$CROSS/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-
export CROSS_COMPILE_ARM32=$CROSS/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
do not set LD when make deconfig
- make CC=clang LD=ld.lld HOSTCC=clang AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip O=out floral_defconfig
+ make CC=clang HOSTCC=clang AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip O=out floral_defconfig
I have changes to this problem in one script but never meet it in another build script. By diffing the two files, I find the correct one does not set LD=ld.lld in make defconfig.
I had to build a version of boost for Android using NDK r18b, I had a hardtime achieving this so I post Question+Answer here as it may help other persons.
Firstly, I tried https://github.com/moritz-wundke/Boost-for-Android, but this was unsuccessful, see How to build boost 1.69.0 for Android with NDK r18b using moritz-wundke/Boost-for-Android?.
Secondly, I tried https://github.com/dec1/Boost-for-Android, but this was unsuccessful too, see How to build boost 1.69.0 for Android with NDK r18b using dec1/Boost-for-Android?.
What are the steps to follow to achieve compilation of boost?
Actually, those scripts were designed for Linux, and they hardly work under Windows. Then, I started from scratch and could finally find the good config under Windows to achieve this. I basically checked how other libraries are compiled (I use QtCreator to deploy on Android, so the compilation window reported me how clang++ has to be invoked, so I write a user-config.jam based on that.
Here are the steps to follow to compile boost 1.68.0 for Android armeabiv7 and x86 using NDK r18b:
Download boost 1.68.0 from boost.org: https://www.boost.org/users/history/version_1_68_0.html
Apply moritz-wundke's patch, else it won't compile (thanks by the way). Take it from here: https://github.com/moritz-wundke/Boost-for-Android/tree/master/patches
Run bootstrap.bat (you'll need it to find a compiler, I have VS 2015 installed so it works just fine)
Then set some environment variables:
set ANDROIDNDKROOT=C:\Android\android-ndk-r18b (change this accordingly)
set NDKVER=r18b
set CLANGPATH=%ANDROIDNDKROOT%\toolchains\llvm\prebuilt\windows-x86_64\bin
Copy user-config.jam to boost folder tools/build/src:
import os ;
local AndroidNDKRoot = [ os.environ ANDROIDNDKROOT ] ;
local AndroidBinariesPath = [ os.environ CLANGPATH ] ;
using clang : armeabiv7a
:
$(AndroidBinariesPath)/clang++
:
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-mthumb
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-Wno-invalid-command-line-argument
<compileflags>-Wno-unused-command-line-argument
<compileflags>-no-canonical-prefixes
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(AndroidNDKRoot)/sources/android/support/include
<compileflags>-DANDROID
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DNDEBUG
<compileflags>-D_REENTRANT
<compileflags>-O2
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
<compileflags>-target
<compileflags>armv7-linux-androideabi
<compileflags>-march=armv7-a
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfp
<compileflags>-fno-builtin-memmove
<compileflags>-fpic
<compileflags>-DHAVE_CONFIG_H
<compileflags>-fno-integrated-as
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/arm-linux-androideabi
<compileflags>-D__ANDROID_API__=18
<archiver>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/arm-linux-androideabi/bin/ar
<ranlib>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/arm-linux-androideabi/bin/ranlib
;
# --------------------------------------------------------------------
using clang : x86
:
$(AndroidBinariesPath)/clang++
:
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-mthumb
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-Wno-invalid-command-line-argument
<compileflags>-Wno-unused-command-line-argument
<compileflags>-no-canonical-prefixes
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(AndroidNDKRoot)/sources/android/support/include
<compileflags>-DANDROID
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DNDEBUG
<compileflags>-D_REENTRANT
<compileflags>-O2
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/windows-x86_64
<compileflags>-target
<compileflags>i686-linux-android
<compileflags>-march=i686
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfp
<compileflags>-fno-builtin-memmove
<compileflags>-fPIC
<compileflags>-mstackrealign
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/i686-linux-android
<compileflags>-D__ANDROID_API__=18
<archiver>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/windows-x86_64/i686-linux-android/bin/ar
<ranlib>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/windows-x86_64/i686-linux-android/bin/ranlib
;
Then, for armeabiv7-a:
Run bjam -q --without-math --without-context --without-coroutine --without-fiber --without-python architecture=arm --ignore-site-config -j4 target-os=android toolset=clang-armeabiv7a link=static threading=multi --layout=tagged --build-dir=build/arm/%NDKVER% --stagedir=stage_arm_%NDKVER% stage
Then, for x86:
Run bjam -q --without-math --without-context --without-coroutine --without-fiber --without-python architecture=arm --ignore-site-config -j4 target-os=android toolset=clang-armeabiv7a link=static threading=multi --layout=tagged --build-dir=build/arm/%NDKVER% --stagedir=stage_arm_%NDKVER% stage
Hopefully, the same steps can be followed to compile 1.69.0 (not tested)
Thanks for the helpful instructions.
moritz-wundke/Boost-for-Android is a great project and the original Boost-for-Android. However, the way it works, it requires constant maintenance in order to support each new combination of the ndk and boost as new versions come out (you can only build for the explicit versions the project has been configured to support). After a long time (boost version 1.53 -> 1.63, and ndk 10->16) where its seemed like the project was no longer being maintained, and my efforts to contact the maintainer were in vain, I decided to fork it, which is why dec1/Boost-for-Android came into existence.
It has the advantage that it does not, in general, need to be updated to support new versions of google's ndk, or boost. They generally build out of the box, or need rare adjustments (but I still test regularly to make sure).
Using dec1/Boost-for-Android is arguably also simpler (certainly than following your instructions above). You can build for any/all architectures (arm64-v8a, armeabi-v7a, x86, x86_64), in one go in a single line of code. And if you dont need a custom build you can simply download prebuilt binaries (boost 1.69.0, with ndk 19 and 18b, both dynamic and static are now also available) from here. There's also an example app to help you test your build.
Im pretty sure that it could be made to work on windows or mac too (possibly with less effort than you spent above), but its a lot easier to just use a virtual machine (eg the free virtualbox) to do the build, and copy the resulting binaries to windows if you really want to develop there.
Nonetheles, moritz-wundke/Boost-for-Android seems to have gotten a new influx of contributions of late, which is good news for everybody. And if you find it more suitable for building boost on windows (or any other platform) then thats great.
Good luck with your projects and thanks again for the insights.
How do I compile and use Boost for the Android NDK? I've tried everything I've found online, from Boost for Android to compiling it myself with the bjam file. However, I do not succeed. When I try compiling it with bjam, I get the following error:
error: toolset gcc initialization:
error: version 'androidR10e' requested but 'g++-androidR10e' not found and version '4.2.1' of default 'g++' does not match
error: initialized from /path/to/android-ndk-r10e/sources/boost/tools/build/v2/user-config.jam:86
Has anyone successfully used Boost with Android NDK R10e?
And when I can compile it, how should I do to use it in my Android app project?
We managed to compile it for NDKr10d. It should be the same for NDKr10e.
The project-config.bjam should point to the gcc compiler from the NDK. Ours looks like this :
import option ;
using gcc : arm : D:\\android\\ndk\\toolchains\\arm-linux-androideabi-4.9\\prebuilt\\windows-x86_64\\bin\\arm-linux-androideabi-g++.exe ;
option.set keep-going : false ;
Then just compile with b2, telling paths to android includes :
b2 --reconfigure <your options>
toolset=gcc-arm
include=<ndk folder>\sources\cxx-stl\gnu-libstdc++\4.9\include
include=<ndk folder>\sources\cxx-stl\gnu-libstdc++\4.9\libs\<target platform>\include
include=<ndk folder>\platforms\<android api version>\arch-arm\usr\include
install --libdir=stage\lib\<target platform>
We're about to move to ndkr10e. Could you tell if boost still works with it ? :)
The simplest way would be to use CrystaX NDK, which contains already built and ready-to-use Boost libraries. And here are examples how to use Boost with CrystaX NDK: 1, 2
Following the boost directions, I was able to build boost 1.60 with NDKr10e on Ubuntu 12.04 (although I suspect very little depends on the host system). Here are my notes:
get and unpack boost source tarball (i used 1.60): boost_1_60_0.tar.bz2
moskewcz#maaya:/scratch/moskewcz/android/src$ ll
total 74M
drwx------ 10 moskewcz moskewcz 4.0K Mar 9 14:14 boost_1_60_0
-rw-rw-r-- 1 moskewcz moskewcz 74M Jan 5 11:15 boost_1_60_0.tar.bz2
follow boost instructions in getting started on unix "Build Custom Binaries" section
use a fresh, empty root to install b2 i.e. /scratch/boost-build-root; use usr as prefix; again following the boost instructions:
moskewcz#maaya:/scratch/moskewcz/android/src/boost_1_60_0/tools/build$ ./bootstrap.sh
moskewcz#maaya:/scratch/moskewcz/android/src/boost_1_60_0/tools/build$ ./b2 install --prefix=/scratch/moskewcz/android/boost-build-root/usr
put b2 in path (again as per instructions)
export PATH=/scratch/moskewcz/android/boost-build-root/usr/bin:$PATH
in some jamfile (i had no ~/user-config.jam, so i created one and used that, maybe there's a better choice of jamfile to create/edit) add some jam-code (?) to define a gcc version (toolset) pointing to a g++ from a standalone toolchain. note that this is a toolchain created with the NDK in the normal fashion following its 'create a standalone toolchain' directions. i am NOT pointing to a g++ inside the NDK itself (that may or may not work, i dunno):
import option ;
using gcc : arm_linux_android_4.9 : /scratch/android-stc/bin/aarch64-linux-android-g++ ;
option.set keep-going : false ;
go to boost project root and build, mostly as per directions. --build-dir may be optional? also added -j8 to do || build
moskewcz#maaya:/scratch/moskewcz/android/src/boost_1_60_0$ b2 -j8 --build-dir=bin.v2 toolset=gcc-arm_linux_android_4.9 stage
note that this tries to build both static and shared libs by default, but building shared libs fails due to android not having librt.so -- according to my research, people claim that under android (some of?) the functionality of librt.so is inside libc.so -- so it may be okay to simply remove -lrt from the linking steps in order to build shared libs for android. i did not attempt this. see:
https://code.google.com/p/android/issues/detail?id=5730
Building Boost for Android with error "cannot find -lrt"
I only managed to build with 10d. Cross compiling Linux->Android using Boost for Android worked straight away with that.
To download a slightly outdated ndk, as not all ndk are immediately supported by Boost for Android, you can use this guide: Where do I find old versions of Android NDK?
Note: I also wanted to specify the toolchain. I had to do it in 2 places:
In build-android.sh, just after the line mentioned here above:
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.9}
In the command line
bash build-android.sh [ndk location] --toolchain=arm-linux-androideabi-4.9
In fact, it worked better when I specified exactly which boost components I wanted with --with-libraries=[comma separated list].
If instead I would build everything, I would get:
...failed updating 38 targets...
...skipped 6 targets...
...updated 10568 targets...
ERROR: Failed to build boost for android!
Done!
Here: http://silverglint.com/boost-for-android/ you can find a simple and painless new way to build a modern (eg 1.64.0) version of boost for android.
Works with clang and gcc.
Also included is a sample app that shows you how to use the boost binaries thus built.
I m trying to build old c code with android standalone tool chain and it keeps failing on
following error :
fatal error: ftw.h: No such file or directory
Not sure how to include these headers from android.
Thanks,
ftw.h is included in android-21 platform (ndk 10c):
MBA-Anton:android-ndk-r10c asmirnov$ find /softdev/android-ndk-r10c -name "ftw.h"
/softdev/android-ndk-r10c/platforms/android-21/arch-arm/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-arm64/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-mips/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-mips64/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-x86/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-x86_64/usr/include/ftw.h
This was an old message, but as I am on a similar ftw-hunt today: as of my writing this, ftw.h does not exist in contemporary android ndk include dirs.
Here are external links to source code for ftw* which may be useful:
http://www.opensource.apple.com/source/ksh/ksh-4/ksh/src/lib/libast/comp/ftw.c
http://www.opensource.apple.com/source/ksh/ksh-4/ksh/src/lib/libast/comp/ftw.h
Also, ftwalk.c is located as above but libast/misc/ftwalk.c (stackoverflow will not let me post a third link cause I'm a newb).
I am trying to use boost library with Android ndk in Eclipse with Windows. I tried to follow this tutorial
I am stuck in the step with "bjam" command in cygwin.
bjam --without-python --without-serialization toolset=gcc-android4.4.3 link=static runtime-link=static target-os=linux --stagedir=android
Error: bjam command not found.
What is bjam? Also I used the boost 1.53 along ndk r8e. Can someone help me with this please?
Android NDK is no longer dependent on Cygwin, so you can build Boost with the NDK from within Windows command prompt (cmd).
In order to make Boost.Build find the NDK, edit boost\tools\build\v2\user-config.jam file and append the following text:
import os ;
androidNDKRoot = C:/android-ndk-r8e ; # put the relevant path
using gcc : android :
$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-g++ :
<compileflags>--sysroot=$(androidNDKRoot)/platforms/android-9/arch-arm
<compileflags>-mthumb
<compileflags>-Os
<compileflags>-fno-strict-aliasing
<compileflags>-O2
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-lstdc++
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/include
<compileflags>-I$(androidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi/include
<compileflags>-D__GLIBC__
<compileflags>-D_GLIBCXX__PTHREADS
<compileflags>-D__arm__
<compileflags>-D_REENTRANT
<archiver>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ar
<ranlib>$(androidNDKRoot)/toolchains/arm-linux-androideabi-4.7/prebuilt/windows/bin/arm-linux-androideabi-ranlib
;
Certainly, instead of c:/android-ndk-r8e you have to put the right location of the NDK on your PC.
Besides, you can select more recent platform API, instead of android-9.
Also note that the NDK supplies several tool-chains, and the above settings point to gcc-4.7. If you prefer to build boost with some other tool-chain, change arm-linux-androideabi-4.7 to the relevant path.
After you've put the configuration in user-config.jam, open cmd, cd to the directory where Boost resides, and invoke bootstrap. Then invoke b2 like this (for example):
b2 --without-python --without-serialization threading=multi link=static runtime-link=static toolset=gcc-android target-os=linux threadapi=pthread --stagedir=android stage
UPDATE: As of 11/2015, older NDK toolchains seem to have issues with the newer Boost versions, causing compiler crash, so consider using a more recent compiler. To do this, just change every 4.7 occurrence in the above script to 4.9. Also, it's worth compiling with a more recent Android API (eg. andoroid-9 -> andoroid-16 or so).