下載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