小智 9
经过测试可正常工作 Ubuntu 20.04 使用我的脚本在 Ubuntu 20.04 中卸载旧版本的 boost 并按照上面的 rams 说明进行操作
#!/bin/bash
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
echo "clear boost dir"
sudo rm -r /usr/local/lib/libboost*
sudo rm -r /usr/local/include/boost
sudo rm -r /usr/local/lib/cmake/[Bb]oost*
sudo rm -f /usr/lib/libboost_*
sudo rm -r /usr/include/boost
Run Code Online (Sandbox Code Playgroud)
小智 6
你可以卸载
apt-get --purge remove libboost-dev libboost-doc
Run Code Online (Sandbox Code Playgroud)
从 boost 网站下载您需要的包,解压并按照解压目录中 index.html 中的“入门”说明进行操作。
Boost可以通过两种方式安装
在某些情况下,我们可能同时安装了这两种类型,这可能会导致版本错误。让我们看看如何卸载两者。
sudo apt-get update
# to uninstall deb version
sudo apt-get -y --purge remove libboost-all-dev libboost-doc libboost-dev
# to uninstall the version which we installed from source
sudo rm -f /usr/lib/libboost_*
Run Code Online (Sandbox Code Playgroud)
然后,如果不满足,我们需要安装其他依赖项
sudo apt-get -y install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev
Run Code Online (Sandbox Code Playgroud)
让我们从链接中下载所需的增强版本。我正在下载1.54版本。然后解压缩并安装它。
# go to home folder
cd
wget http://downloads.sourceforge.net/project/boost/boost/1.54.0/boost_1_54_0.tar.gz
tar -zxvf boost_1_54_0.tar.gz
cd boost_1_54_0
# get the no of cpucores to make faster
cpuCores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk '{print $NF}'`
echo "Available CPU cores: "$cpuCores
sudo ./b2 --with=all -j $cpuCores install
Run Code Online (Sandbox Code Playgroud)
现在让我们检查安装的版本
cat /usr/local/include/boost/version.hpp | grep "BOOST_LIB_VERSION"
Run Code Online (Sandbox Code Playgroud)
你会像下面这样
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_54"
Run Code Online (Sandbox Code Playgroud)
已安装Boost 1.54版
就是这样,它对我有用。如果您遇到任何问题,请告诉我。