Skip to content

Instantly share code, notes, and snippets.

@chewwt
Last active August 31, 2020 10:21
Show Gist options
  • Save chewwt/eb743e63f088928eedaa9604f8768d2c to your computer and use it in GitHub Desktop.
Save chewwt/eb743e63f088928eedaa9604f8768d2c to your computer and use it in GitHub Desktop.
Compile boost from source

Compile Boost from source

For linking libboost-python to the correct python. Apt installation uses system python.

Switch to the desired pyenv

Get python headers path using python-config --includes --libs and add the path in ~/.zshrc:

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/home/ruth/.pyenv/versions/3.6.12/include/python3.6m"

Download latest boost

tar xzvf boost_<version>.tar.gz
cd boost_<version>/

sudo apt-get update
sudo apt-get install build-essential g++ python3-dev autotools-dev libicu-dev build-essential libbz2-dev

echo "using python : : ~/.pyenv/versions/3.6.12/bin/python ;" > ~/user-config.jam
./bootstrap.sh --prefix=/usr/local
./b2
sudo ./b2 -j8 install

sudo ldconfig

Can add multiple pythons versions in user-config.jam to build for multiple python versions. See here

Alternative to using user-config.jam:

./bootstrap.sh --with-python=$(which python3) --prefix=/usr/local

Tested with Ubuntu 20.04 and boost 1.7.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment