build boost for current host

step0、参考

step1、安装依赖

所有时Terminal + Shell + GNU CoreUtils
下载时cURL
解压时tar + bzip2
编译时CPythongcc / GCC | Clang / LLVM
运行时
  • glibc ( libc.solibpthread.sold-linux-x86-64.so )

step2、使用curl命令下载boost源码包 (

curl -LO https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2

step3、使用tar解压boost源码包

tar vxf boost_1_73_0.tar.bz2

step4、进入boost_1_73_0目录

cd boost_1_73_0

step5、查看boost_1_73_0目录的内容

step6、生成b2命令和project-config.jam

./bootstrap

step7、通过./b2命令配置编译参数并安装

./b2 [option]... [property]... [target]...
公共property可取值说明
target-oslinux | darwin | android交叉编译时候,需要设置目标系统
toolsetclang-arm设置使用哪个toolset
variantdebug | release | debug,release
linkstatic | shared | static,shared生成静态库还是动态库
runtime-linkstatic | shared静态链接还是动态链接的方式进行链接库
threadingsingle | multi是否使用多线程
includeDIR设置额外的头文件搜索目录
库名称 库文件名 依赖库
Boost.MPI libboost_mpi.{a | so | dylib} open-mpi
Boost.Log
libboost_log.{a | so | dylib}
libboost_log_setup.{a | so | dylib}
Boost.Test libboost_unit_test_framework.a
Boost.Math libboost_math_xx.{a | so | dylib}
Boost.Wave libboost_wave.{a | so | dylib}
Boost.Fiber libboost_fiber.{a | so | dylib}
Boost.Timer libboost_timer.{a | so | dylib}
Boost.Regex libboost_regex.{a | so | dylib}
Boost.Nowide libboost_nowide.{a | so | dylib}
Boost.Thread libboost_thread.{a | so | dylib}
Boost.Atomic libboost_atomic.{a | so | dylib}
Boost.Locale libboost_locale.{a | so | dylib}
Boost.Python libboost_python.{a | so | dylib} CPython
Boost.System libboost_system.{a | so | dylib}
Boost.Random libboost_random.{a | so | dylib}
Boost.Chrono libboost_chrono.{a | so | dylib}
Boost.Context libboost_context.{a | so | dylib}
Boost.Contract libboost_contract.{a | so | dylib}
Boost.Coroutine libboost_coroutine.{a | so | dylib}
Boost.Container libboost_container.{a | so | dylib}
Boost.Date_Time libboost_date_time.{a | so | dylib}
Boost.Exception libboost_exception.{a | so | dylib}
Boost.Filesystem libboost_filesystem.{a | so | dylib}
Boost.Stacktrace libboost_stacktrace.{a | so | dylib}
Boost.Iostreams libboost_iostreams.{a | so | dylib}
Boost.Serialization libboost_serialization.{a | so | dylib}
Boost.Program_options libboost_program_options.{a | so | dylib}

示例:

./b2 install \
    -q \
    -d+2 \
    -j$(nproc) \
    --reconfigure \
    --without-python \
    --prefix=/usr/local/opt/boost \
    -sICU_PATH=/usr/local/opt/icu4c \
    -sICONV_PATH=/usr/local/opt/libiconv \
    link=static,shared \
    variant=release \
    threading=multi