Skip to content

Boost.Python compilation

Zakant edited this page Jun 21, 2017 · 2 revisions

1. Get Boost

2. Prepare boost

NOTE: If you use MSVC from VisualStudio 2017 start a Developer Command Prompt as otherwise the build will not work.

  • Start a Developer Command Prompt or a normal command prompt and go to the boost directory.
  • Run bootstrap.bat. This will compile the boost build tools and prepare everyting for the real build.
  • b2.exe and bjam.exe should now be present in the boost directory.

3. Prepare python build

Make sure your python version matches the boost version you are going to build. Python x64 is required for Boost.Python x64.

  • First copy .\tools\build\example\user-config.jam to .\user-config.jam.
  • Open the newly made copy with a text editor.
  • In the last line (starting with # using python : ...) remove the # character.
  • Change the settings so that they look like this: using python : 3.6 : <PythonPath> : <PythonPath>\\include : <PythonPath>\\libs ;. Make sure to use \\ on windows machines to escape the backslash.

4. Build Boost.Python

  • Change back to the command prompt.
  • Run bjam --user-config=user-config.jam --with-python python-debugging=off threading=multi link=shared variant=release address-model=64 stage. This will compile python and put the resulting files into .\stage\lib.
  • By removing address-model=64 from the call, the x86 version is build. By removing link=shared from the call the static version is build. However this seems to be not-working with python.
  • Rename boost_python3-vc141-mt-1_64.lib to boost_python-vc141-mt-1_64.lib (remove the 3). Otherwise the compiler will not be able to find it. The .dll must keep the 3 in the name.
Clone this wiki locally