Ubuntu用android-ndk-r15c编译boost_1_65_1

方法一(最简单的):

下载:android-ndk-r16-beta1

然后下载Boost-for-Android:https://github.com/moritz-wundke/Boost-for-Android 

然后到Boost-for-Android的目录执行:

./build-android.sh /path/to/android-ndk-r16-beta1

方法二(较复杂):

解压:

unzip android-ndk-r15c-linux-x86_64.zip

unzip boost_1_65_1.zip

cd boost_1_65_1/

./bootstrap.sh

vim tools/build/example/user-config.jam

import os ;  
   
if [ os.name ] = CYGWIN || [ os.name ] = NT {  
androidPlatform = windows-x86_64 ;  
}  
else if [ os.name ] = LINUX {  
androidPlatform = linux-x86_64 ;  
}  
else if [ os.name ] = MACOSX {  
androidPlatform = darwin-x86 ;  
}  
   
modules.poke : NO_BZIP2 : 1 ;  
ANDROID_NDK = /path/to/android-ndk-r15c ;
using gcc : android4.9 : $(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :  
<archiver>$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar  
<ranlib>$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib  
<compileflags>--sysroot=$(ANDROID_NDK)/platforms/android-9/arch-arm  
<compileflags>-I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/include  
<compileflags>-I$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include  

<compileflags>-DNDEBUG  
<compileflags>-D__GLIBC__  
<compileflags>-DBOOST_FILESYSTEM_VERSION=3  
<compileflags>-lstdc++  
<compileflags>-lgnustl_shared  
<compileflags>-mthumb  
<compileflags>-fno-strict-aliasing  
<compileflags>-std=gnu++11  
<compileflags>-O2
;  

cp  tools/build/example/user-config.jam  tools/build/src/

./b2 --with-system --with-serialization toolset=gcc-android4.9 link=static runtime-link=static target-os=linux --stagedir=android

静态库就生成在

boost_1_65_1/android/lib文件夹下

原文地址:https://www.cnblogs.com/bugutian/p/7760602.html