Skip to content

Compile boost on Windows

Tested with boost 1.83.0

Requirements

  • cmake (tested with v3.26.1)
  • gcc (tested with v10.3)

Download source

You can download source code from this GitHub But be carreful, don't download the 'source code' but the 'realeased', because .tar.gz or zip source code doesn't contains tools to compile boost.

If the folder inside the downloaded archive is called boost-boost-<version> you got the wrong one. So download the released source code, and you normally should have a folder called boost-<version>, with a full filled tools folder.

Bootstrap

bash
cd <SOURCE_DIR>
./bootstrap.sh --prefix=<SOURCE_DIR>/build --with-toolset=gcc

This will generate a b2 executable in the source directory.

Compile

On Windows we can't use <SOURCE_DIR>/install as prefix because they are already a file named 'INSTALL' in the source directory, so we will use <SOURCE_DIR>/install_prefix instead.

And on windows, you also need to add --layout=system release address-model=64 to the b2 command, to avoid generation of platform name in the final librairies, For example if you don't add this argument you will get (For example: libboost_atomic-vc143-mt-gd-x32-1_83.lib)

bash
./b2 install --prefix=<SOURCE_DIR>/prefix_install --layout=system release address-model=64

Python binding

bash
./bootstrap.sh --prefix=<SOURCE_DIR>/build --with-toolset=gcc --with-python=<PYTHON_PATH>
bash
b2 release link=shared --python=3.9  --build-type=complete --prefix=./prefix_install --threading=multi

you can also edit the project-config.jam file to add the python path.

References