27

I've installed the boost libraries on Linux Mint 12 using the command sudo apt-get install libboost-dev libboost-doc, which installs the default version available in the repositories. However, the project I have to do needs the 1.44 version of boost. How do I uninstall the default (current) version 1.46 and install 1.44?

I couldn't find the documentation on the boost website to install boost from the .tar.gz package.

Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
freinn
  • 1,049
  • 5
  • 14
  • 23
  • I'm trying to do the install but I'm having some errors, I'm doing the point 6, and $ c++ -I path/to/boost_1_48_0 example.cpp -o example \ ~/boost/stage/lib/libboost_regex-gcc34-mt-d-1_36.a, I dont understand that command, it produces the output g++ -I /usr/local/boost_1_48_0 example.cpp -o example -L~/boost/stage/lib/ -lboost_regex-gcc34-mt-d-1_36 /usr/bin/ld: cannot find -lboost_regex-gcc34-mt-d-1_36 collect2: ld returned 1 exit status – freinn Dec 08 '11 at 13:05

6 Answers6

37

Boost can installed by two ways

  • Deb package
  • wget and install manually

In some case we might have installed by both type which can cause version error. Lets see how to uninstall both.

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

Then we need to install other dependencies if they are not met

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

Lets download the boost version which we need from the link. I am downloading the 1.54 version. Then untar and install it.

# 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

Now let's check the installed version

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

You will see something like below

//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_54"

Version 1.54 of boost is installed

That's it, it worked for me. Let me know if you face any issues.

Adam
  • 2,726
  • 1
  • 9
  • 22
ram
  • 874
  • 9
  • 12
  • 6
    May need to run the boostrap before `./b2` for other versions of boost... `./bootstrap.sh --with-libraries=atomic,date_time,exception,filesystem,iostreams,locale,program_options,regex,signals,system,test,thread,timer,log` – Josh Hibschman Oct 17 '18 at 15:07
  • @ram Do we still need `sudo apt autoremove` for DEB version? – Cloud Cho Sep 23 '19 at 19:55
  • 1
    @ram shouldn't we look for version at `/usr/include` not `/usr/local/include`? – Cloud Cho Sep 23 '19 at 21:42
  • 2
    @CloudCho depending upon the installation it will be present in `/usr/include` or `/usr/local/include`. Try one if you get `No such file or directory` try the other one. – ram Sep 24 '19 at 02:57
  • 1
    But I would like to install it on usr/include specifically, how can I do that? – Meric Ozcan May 18 '21 at 16:06
8

Tested working Ubuntu 20.04 Use my script to uninstall your older version of boost in Ubuntu 20.04 and follow rams instructions above

#!/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
greybeard
  • 2,249
  • 8
  • 30
  • 66
  • Not a Linux expert, but what about the libraries located in `/usr/lib/x86_64-linux-gnu`? – intrigued_66 Jun 24 '23 at 18:08
  • And i'm on Ubuntu and have no Boost libraries in `/usr/local/lib/libboost`? – intrigued_66 Jun 24 '23 at 18:09
  • To the [editor](https://stackoverflow.com/review/suggested-edits/34621934), always leave a comment to the author (ask) before changing the meaning of their answer, even if you believe your way is more correct. – Al.G. Jul 02 '23 at 12:28
8

You can uninstall with

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

Download the package you need from boost website, extract and follow "getting started" instructions found inside index.html in the extracted directory.

savamane
  • 148
  • 1
  • 7
  • I've done what you told me, but were 12 things not installed, and 52 skipped ones, is that normal?? – freinn Dec 08 '11 at 12:40
  • Yes that is normal, and it is probably fine unless one of the packages that didn't build is one you will depend on, but in my experiences the core more commonly used packages will be available and some of the less frequently used packages are the ones that don't build well on all platforms. So just run with it and it will probably be ok. – Chris Desjardins Mar 10 '13 at 10:51
  • and then: apt-get autoremove – Janek Olszak Nov 15 '13 at 18:36
3

Downgrade your boost version. I'm not familiar with Mint, but assuming it is deb-based, you can do:

apt-cache show libboost-dev

to see all installable version and install a specific version with

sudo apt-get install libboost-dev=1.42.0.1

There are also convenience packages for the major boost versions:

sudo apt-get install libboost1.44-dev
thiton
  • 35,651
  • 4
  • 70
  • 100
  • Good job but it doesnt works: E: Version '1.44' for 'libboost-dev' was not found – freinn Dec 08 '11 at 12:04
  • Thanks, but doesnt work again...Can you explain me what happened to me in the comment from my question?? – freinn Dec 08 '11 at 13:13
  • Distributions like Mint retire old versions of packages. It won't find 1.44 because the file doesn't exist any more. (Because the newer versions are available.) They can't afford to keep around every old version forever. – greyfade Nov 13 '13 at 00:12
1

As @savamane wrote you can uninstall it with

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

Another suggestion to install the .deb packages as suggested here. (Download the one fitted for your architecture though).

For still supported distros, you can simply search for the package at the distributions at http://packages.ubuntu.com/. For example libboost-system1.46.1 can be found in under the precise -> Libraries tab.

For unsupported distros, there is still a chance to find them at http://archive.ubuntu.com/. For example can libboost-all-dev_1.40.0.1_amd64.deb be found in http://archive.ubuntu.com/ubuntu/pool/universe/b/boost-defaults/.

Løiten
  • 3,185
  • 4
  • 24
  • 36
0

This is how you install a specific Boost version:

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
sjaustirni
  • 3,056
  • 7
  • 32
  • 50