Project

General

Profile

Actions

Boost FAQ

Installing boost libraries to /usr/local

The following instructions are for those who want to install the latest version of the boost libraries and have root access.

The following commands would install the latest version of the boost libraries (1.72.0 at the time of writing) to /usr/local, assuming you have root access to your machine.
If you don't have root access, skip to the next section.
Note: if you are using Ubuntu, make sure that you have installed libbz2-dev, otherwise not all libraries required by NFD will be installed.

wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2
tar xf boost_1_72_0.tar.bz2
cd boost_1_72_0
./bootstrap.sh
sudo ./b2 --prefix=/usr/local install

The following commands should allow compilation and run of NFD with custom install of boost libraries:

cd NFD
./waf configure --boost-includes=/usr/local/include --boost-libs=/usr/local/lib
./waf
sudo ./waf install

# if on Linux
sudo ldconfig

Installing boost libraries to a non-privileged location

Follow these instructions if you are trying to install the boost libraries to a non-privileged location (i.e., you do not have root access).

Normally, to compile and install boost libraries in non-privileged mode, you would need to issue following commands (e.g., for boost version 1.72.0):

export BOOSTDIR=/home/non-privileged-user/boost
wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2
tar xf boost_1_72_0.tar.bz2
cd boost_1_72_0
./bootstrap.sh
./b2 --prefix="$BOOSTDIR" install

Common pitfalls

The common pitfalls is with the boost iostreams library, which is required by NFD, but failed to build because of the missing bzip2 library.
This problem can be easily fixed by downloading and installing the bzip2 library, e.g., using the following steps:

wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make PREFIX="$BOOSTDIR" CFLAGS="-fPIC -O2 -g" install

After the bzip2 library is installed, you may recompile and reinstall the boost libraries using custom compilation flags:

./b2 --prefix=$BOOSTDIR cxxflags=-I$BOOSTDIR/include linkflags=-L$BOOSTDIR/lib install

Alternatively, you can solve this particular problem by installing development package for bzip2 library (if you have root access). For example, on Ubuntu it would be the following command:

sudo apt install libbz2-dev

And then compiling and installing boost without custom compilation flags:

./b2 --prefix="$BOOSTDIR"

The following commands should allow compilation and execution of NFD with a custom-prefix installation of boost libraries:

cd NFD
./waf configure --prefix="$BOOSTDIR" --boost-includes="$BOOSTDIR"/include --boost-libs="$BOOSTDIR"/lib
./waf
./waf install
LD_LIBRARY_PATH="$BOOSTDIR"/lib "$BOOSTDIR"/nfd

Note that LD_LIBRARY_PATH="$BOOSTDIR"/lib is necessary on Linux platform in order for the dynamic linker to find libraries installed in a location different from one of the folders specified in /etc/ld.so.conf.

Updated by Davide Pesavento over 4 years ago · 3 revisions