卸载boost并安装另一个版本

Uninstall boost and install another version

本文关键字:另一个 版本 安装 boost 卸载      更新时间:2023-10-16

我已经在Linux Mint 12上使用命令sudo apt-get install libboost-dev libboost-doc安装了boost库,该命令安装了存储库中可用的默认版本。然而,我要做的项目需要1.44版本的boost。如何卸载默认(当前)版本1.46并安装1.44?

我在boost网站上找不到从.tar.gz包安装boost的文档。

Boost有两种安装方式

  • Deb包
  • wget并手动安装

在某些情况下,我们可能同时安装了这两种类型,这会导致版本错误。让我们看看如何卸载这两个。

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_*

如果不满足,我们需要安装其他依赖项

sudo apt-get -y install build-essential g++ python-dev autotools-dev libicu-dev libbz2-dev

让我们从链接下载我们需要的boost版本。我正在下载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
./bootstrap.sh  # this will generate ./b2
sudo ./b2 --with=all -j $cpuCores install

现在检查已安装的版本

cat /usr/local/include/boost/version.hpp | grep "BOOST_LIB_VERSION"

你会在

下面看到类似的内容
//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_54"

安装1.54版本的boost

就是这样,它对我有效。

可以使用

卸载
apt-get --purge remove libboost-dev libboost-doc

从boost网站下载所需的包,解压并按照解压目录index.html中的"getting started"说明操作

在Ubuntu 20.04中使用我的脚本卸载旧版本的boost,并按照上面的ram指示操作

#!/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

降级boost版本。我不熟悉Mint,但假设它是基于债务的,你可以这样做:

apt-cache show libboost-dev

查看所有可安装版本,并使用

安装特定版本
sudo apt-get install libboost-dev=1.42.0.1

对于主要的boost版本也有方便的包:

sudo apt-get install libboost1.44-dev

就像@savamane写的,你可以用

卸载它

apt-get --purge remove libboost-dev libboost-doc

另一个安装.deb包的建议。(请下载适合您的架构的版本)。

对于仍然支持的发行版,您可以简单地在http://packages.ubuntu.com/的发行版上搜索该包。例如,libboost-system1.46.1可以在precise -> Libraries标签下找到。

对于不支持的发行版,仍然有机会在http://archive.ubuntu.com/。例如libboost-all-dev_1.40.0.1_amd64.deb可以在http://archive.ubuntu.com/ubuntu/pool/universe/b/boost-defaults/。

安装特定Boost版本的方法:

cd boost_1_54_0/
./bootstrap.sh --with-libraries=atomic,date_time,exception,filesystem,iostreams,locale,program_options,regex,signals,system,test,thread,timer,log
sudo ./b2 install