基于ndk的boost编译

记录一下编译安卓下的c++boost库,参考了 https://github.com/moritz-wundke/Boost-for-Android

(我自己的系统是ubuntu)

编译

git clone https://github.com/moritz-wundke/Boost-for-Android 
git clone https://gitee.com/qweasdzxc1cc/Boost-for-Android # 如果网速慢可以用gitee
cd Boost-for-Android
./build-android.sh /home/cc/data/cc/Android/Sdk/ndk/23.0.7344513 --boost=1.74.0 --prefix=/home/cc/data/cc/zhuandaixin/Boost-for-Android/install --arch=arm64-v8a --target-version=21 

参数说明:

  • /home/cc/data/cc/Android/Sdk/ndk/23.0.7344513 : ndk的目录
  • --boost=1.74.0 : boost的版本(会自动在 Boost-for-Android 目录下下载 boost源码包)
  • --prefix= : 指定安装目录
  • --arch=arm64-v8a : 指定架构
  • --target-version=21 : 指定安卓 API level

上述命令默认编译的是静态库,如果需要编译动态库修改 build-android.shlink 选项 将static改成shared,如下:

./b2 -q                          \
        -d+2                         \
        --ignore-site-config         \
        -j$NCPU                      \
        target-os=${TARGET_OS}       \
        toolset=${TOOLSET_ARCH}      \
        $cflags                      \
        $cxxflags                    \
        link=shared                  \
        threading=multi              \
        --layout=${LAYOUT}           \
        $WITHOUT_LIBRARIES           \
        $PYTHON_BUILD                \
        -sICONV_PATH=`pwd`/../libiconv-libicu-android/$ARCH \
        -sICU_PATH=`pwd`/../libiconv-libicu-android/$ARCH \
        --build-dir="./../$BUILD_DIR/build/$ARCH" \
        --prefix="./../$BUILD_DIR/out/$ARCH" \
        $LIBRARIES                   \
        $LIBRARIES_BROKEN            \
        install 2>&1                 \
posted @ 2021-11-09 11:12  cc96  阅读(1049)  评论(0编辑  收藏  举报