Boost FAQ » History » Version 3
Davide Pesavento, 04/21/2020 11:21 AM
| 1 | 1 | Alex Afanasyev | Boost FAQ |
|---|---|---|---|
| 2 | ========= |
||
| 3 | |||
| 4 | ## Installing boost libraries to ``/usr/local`` |
||
| 5 | |||
| 6 | 3 | Davide Pesavento | *The following instructions are for those who want to install the latest version of the boost libraries and have root access.* |
| 7 | 1 | Alex Afanasyev | |
| 8 | 3 | Davide Pesavento | 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. |
| 9 | 1 | Alex Afanasyev | If you don't have root access, skip to the next section. |
| 10 | 3 | Davide Pesavento | Note: if you are using Ubuntu, make sure that you have installed ``libbz2-dev``, otherwise not all libraries required by NFD will be installed. |
| 11 | 1 | Alex Afanasyev | |
| 12 | 3 | Davide Pesavento | wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2 |
| 13 | tar xf boost_1_72_0.tar.bz2 |
||
| 14 | cd boost_1_72_0 |
||
| 15 | 1 | Alex Afanasyev | ./bootstrap.sh |
| 16 | sudo ./b2 --prefix=/usr/local install |
||
| 17 | |||
| 18 | |||
| 19 | The following commands should allow compilation and run of NFD with custom install of boost libraries: |
||
| 20 | |||
| 21 | cd NFD |
||
| 22 | ./waf configure --boost-includes=/usr/local/include --boost-libs=/usr/local/lib |
||
| 23 | ./waf |
||
| 24 | sudo ./waf install |
||
| 25 | |||
| 26 | 3 | Davide Pesavento | # if on Linux |
| 27 | 1 | Alex Afanasyev | sudo ldconfig |
| 28 | |||
| 29 | |||
| 30 | ## Installing boost libraries to a non-privileged location |
||
| 31 | |||
| 32 | 3 | Davide Pesavento | *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).* |
| 33 | 1 | Alex Afanasyev | |
| 34 | 3 | Davide Pesavento | 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): |
| 35 | 1 | Alex Afanasyev | |
| 36 | export BOOSTDIR=/home/non-privileged-user/boost |
||
| 37 | 3 | Davide Pesavento | wget https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2 |
| 38 | tar xf boost_1_72_0.tar.bz2 |
||
| 39 | cd boost_1_72_0 |
||
| 40 | 1 | Alex Afanasyev | ./bootstrap.sh |
| 41 | 3 | Davide Pesavento | ./b2 --prefix="$BOOSTDIR" install |
| 42 | 1 | Alex Afanasyev | |
| 43 | |||
| 44 | ## Common pitfalls |
||
| 45 | |||
| 46 | The common pitfalls is with the **boost iostreams** library, which is required by NFD, but failed to build because of the missing bzip2 library. |
||
| 47 | 3 | Davide Pesavento | This problem can be easily fixed by downloading and installing the bzip2 library, e.g., using the following steps: |
| 48 | 1 | Alex Afanasyev | |
| 49 | wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz |
||
| 50 | 3 | Davide Pesavento | tar xf bzip2-1.0.6.tar.gz |
| 51 | 1 | Alex Afanasyev | cd bzip2-1.0.6 |
| 52 | 3 | Davide Pesavento | make PREFIX="$BOOSTDIR" CFLAGS="-fPIC -O2 -g" install |
| 53 | 1 | Alex Afanasyev | |
| 54 | 3 | Davide Pesavento | After the bzip2 library is installed, you may recompile and reinstall the boost libraries using custom compilation flags: |
| 55 | 1 | Alex Afanasyev | |
| 56 | 2 | Davide Pesavento | ./b2 --prefix=$BOOSTDIR cxxflags=-I$BOOSTDIR/include linkflags=-L$BOOSTDIR/lib install |
| 57 | 1 | Alex Afanasyev | |
| 58 | 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: |
||
| 59 | |||
| 60 | 3 | Davide Pesavento | sudo apt install libbz2-dev |
| 61 | 1 | Alex Afanasyev | |
| 62 | And then compiling and installing boost without custom compilation flags: |
||
| 63 | |||
| 64 | 3 | Davide Pesavento | ./b2 --prefix="$BOOSTDIR" |
| 65 | 2 | Davide Pesavento | |
| 66 | 3 | Davide Pesavento | The following commands should allow compilation and execution of NFD with a custom-prefix installation of boost libraries: |
| 67 | 1 | Alex Afanasyev | |
| 68 | cd NFD |
||
| 69 | 3 | Davide Pesavento | ./waf configure --prefix="$BOOSTDIR" --boost-includes="$BOOSTDIR"/include --boost-libs="$BOOSTDIR"/lib |
| 70 | 1 | Alex Afanasyev | ./waf |
| 71 | ./waf install |
||
| 72 | 3 | Davide Pesavento | LD_LIBRARY_PATH="$BOOSTDIR"/lib "$BOOSTDIR"/nfd |
| 73 | 1 | Alex Afanasyev | |
| 74 | 3 | Davide Pesavento | 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`. |