Android NDK不再依賴於Cygwin,因此您可以在Windows命令提示符(cmd
)內使用NDK構建Boost。
爲了使Boost.Build
找到NDK,編輯boost\tools\build\v2\user-config.jam
文件並添加以下文字:
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
;
當然,代替c:/android-ndk-r8e
你必須把NDK的正確的位置您的PC上。
此外,您可以選擇更新的平臺API,而不是android-9
。
另請注意,NDK提供多個工具鏈,上述設置指向gcc-4.7。如果您更喜歡使用其他工具鏈構建boost,請將arm-linux-androideabi-4.7
更改爲相關路徑。
將配置放入user-config.jam之後,打開cmd
,cd
到Boost所在的目錄,然後調用bootstrap
。然後調用b2
像這樣(例如):
b2 --without-python --without-serialization threading=multi link=static runtime-link=static toolset=gcc-android target-os=linux threadapi=pthread --stagedir=android stage
UPDATE:作爲二千零一十五分之一十一,老年NDK工具鏈似乎與較新版本的加速問題,造成編譯器崩潰,所以考慮使用更新的編譯器。要做到這一點,只需將上述腳本中的每4.7次出現更改爲4.9即可。另外,值得使用更新的Android API進行編譯(例如,andoroid-9 - > andoroid-16左右)。
d:\ android_ndk_with_boost \機器人-NDK-R8E \源\ boost_1_53_0 \工具\建立\ V2> B2 --without-蟒--without序列化線程=多連桿=靜態運行時利 NK =靜態工具集= gcc-android4.6 target-os = linux threadapi = pthread --stagedir = an droid D:/ android_ndk_with_boost/android-ndk-r8e/sources/boost_1_53_0/tools/build/v2 /至 ols \ gcc.jam :78:in gcc.init from module gcc error:toolset gcc initialization: error:provided command'D:/ android_ndk_with_boost/android-ndk-r8e/toolchains/ar m-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g ++'not foun d – user2508941
我得到這個錯誤。 ...抱歉不能把它們放在一起.. – user2508941
@ user2508941什麼是「toolset = gcc-android4.6」?你是如何在你的user-config.jam中定義的? (使用pastebin.com或類似的網站來把錯誤。) –