Building Boost.Python

14,380

1.) Unzip boost_1_55_0.zip

2.) Prepare to use the Boost Library Binaries

Go to the boost_1_55_0 root directory and open a command prompt and type following commands:

Bootstrap

3.) Find user-config.jam:

Type following in the command prompt:

ECHO %HOMEDRIVE%%HOMEPATH%

4.) If the user-config.jam is in your homedrive directory please change it there as followed:

ATTENTION:

The .jam language rates a “whitespace” as a separation of arguments!

# -------------------
# MSVC configuration.
# -------------------

# Configure msvc (default version, searched for in standard locations and PATH).
# using msvc ;

# Configure specific msvc version (searched for in standard locations and PATH).
using msvc : 10.0 : C:\\app\\tools\\MSVisualStudio2010\\VC\\bin\\cl.exe ;

….

# ---------------------
# Python configuration.
# ---------------------

# Configure specific Python version.
# using python : 3.1 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;

using python 
    : 2.5                   # Version
    : C:\\app\\tools\\Python25\\python.exe      # Python Path
    : C:\\app\\tools\\Python25\\include         # include path
    : C:\\app\\tools\\Python25\\libs            # lib path(s)
    : <define>BOOST_ALL_NO_LIB=1
    ;

5.) Build the Libraries AFTER configuration!!

Go to the boost_1_55_0 root directory and open a command prompt and type following commands:

.\b2

6.) Copy the user-config.jam to \boost_1_55_0\libs\python\example\tutorial

7.) Go further to \boost_1_55_0\stage\lib\

Rename libboost_python-vc100-mt-gd-1_55.lib to boost_python-vc100-mt-gd-1_55.lib and copy it to

\boost_1_55_0\libs\python\example\tutorial

8.) Now you should have all of these files in the \boost_1_55_0\libs\python\example\tutorial directory

hello.cpp
hello.py
user-config.jam
Jamroot
boost_python-vc100-mt-gd-1_55.lib
bjam.exe

9.) Open a command prompt in \boost_1_55_0\libs\python\example\tutorial

And type following command:

bjam

10.) After successful building..

You should have this file in the directory:

hello_ext.dll

rename this file to:

hello_ext.pyd
Share:
14,380
ChangeMyName
Author by

ChangeMyName

Updated on June 14, 2022

Comments

  • ChangeMyName
    ChangeMyName almost 2 years

    I am trying to build Boost.Python according to the instructions on the official website.

    My OS is Windows 7 64-bit, the compiler is MSVC11, the boost is 1.54.

    =================== Install Boost ==================

    To install basic Boost, I downloaded the boost library from its website, unzip it to my local disk. The path is C:\local\boost_1_54_0.

    =============== Install Boost.Python ===============

    I then find that Boost.Python need to be built separately. So I followed the Boost.Python instruction.

    =============== Install Boost.Build ================

    And at stage 3.1.2, Boost.Build is required. So I, again, followed the steps and install Boost.Build at C:\local\boost_1_54_0\BoostBuild, and added C:\local\boost_1_54_0\BoostBuild\bin into the Path enviroment variable.

    Then I am stuck at stage 3.1.3 and 3.1.4, where the instruction says

    3.cd into the libs/python/example/quickstart/ directory of your Boost installation, which contains a small example project.

    4.Invoke bjam. Replace the “stage“ argument from the example invocation from section 5 of the Getting Started Guide with “test,“ to build all the test targets. Also add the argument “--verbose-test” to see the output generated by the tests when they are run.

    On Windows, your bjam invocation might look something like:

    C:\boost_1_34_0\…\quickstart> bjam toolset=msvc --verbose-test test

    I've typed the command line that the instruction told me and I am sure that I am in the right directory. However, there is no bjam or b2 in the quickstart folder (they are at the root direcroty of Boost and C:\local\boost_1_54_0\BoostBuild\bin).

    I even tried to copy these two files to the quickstart folder, but doesn't work at all.

    I am not very familiar with the Windows management mechanism, thus am not sure if the Path is the key to my question. I guess after I added the bin folder to the PATH, the OS will automatically link my bjam toolset=msvc --verbose-test test to the bjam in the C:\local\boost_1_54_0\BoostBuild\bin folder?

    Can anyone help me with this? :)

  • Szał Pał
    Szał Pał almost 10 years
    What if (after Bootstrap), user-config.jam isn't in my homedrive dir? Should I copy it there?
  • Flo
    Flo almost 10 years
    i copied there and also in the folder (\boost_1_55_0\libs\python\example\tutorial)
  • Cinch
    Cinch about 9 years
    project-config.jam was my own file that I changed. Apparently, Boost doesn't configure its own project-config file to use the "gcc" or "mingw" compiler even if you specify it. Change "using msvc" to "using gcc" and it should work.