Linux下boost库的编译、安装详解

下载boost源码

boost下载地址

解压到一个目录

tar -zxvf boost_1_66_0.tar.gz

1、正常编译:

进入boost_1_66_0目录中

cd boost_1_66_0
./bootstrap.sh --with-libraries=all --with-toolset=gcc

--with-liraries:需要编译的库
--with-toolset:编译时使用的编译器

安装boost库

./b2 install --prefix=/usr

--prefix:boost库的安装目录,不加此参数,默认安装在/usr/local目录下

2、交叉编译:

创建脚本xcompile_boost.sh,内容如下:

#xcompile_boost.sh

mfile=project-config.jam

if [ -e ${mfile} ];then
    rm ${mfile}
    echo "rm ${mfile}"
fi

./bootstrap.sh 
--with-libraries=system,filesystem,regex 
--prefix=/home/moxo/msoft/boost_1_65_1/prefix

if [ -e ${mfile} ];then
    mhost="/home/moxo/msoft/openwrt-guoxin/bin/arm-openwrt-linux-gnueabi-gcc -fPIC"
    sed -i "/using gcc/c using gcc : arm : ${mhost} ; " ${mfile}
fi

echo "After 5s start compile"
sleep 5s
./b2

echo "Afer 5s start install"
sleep 5s
./b2 install
原文地址:https://www.cnblogs.com/smallredness/p/9245127.html