c++boost.gif (8819 bytes)Building an Extension Module

The build process for Boost is currently undergoing some evolution, and, it is to be hoped, improvement. The following facts may help:


Makefiles for various platforms and a Visual Studio project reside in the Boost subdirectory libs/python/build. Build targets include:
There is a group of makefiles with support for simultaneous compilation on multiple platforms and a consistent set of features that build the boost_python library for static linking, the comprehensive test, and all examples in libs/python/example: Usage of these makefiles is described here.
There is another group of makefiles for GNU make. These makefiles are less redundant than the makefiles in the group above, but the list of compilation targets is not as complete and there is no support for simultaneous compilation on multiple platforms.
A project workspace for Microsoft Visual Studio is provided at libs/python/build/build.dsw. The include paths for this project may need to be changed for your installation. They currently assume that python has been installed at c:\tools\python. Three configurations of all targets are supported:

When extension modules are built with Visual C++ using -D_DEBUG, Python defaults to force linking with a special debugging version of the Python DLL. Since this debug DLL isn't supplied with the default Python installation for Windows, Boost.Python uses boost/python/detail/wrap_python.hpp to temporarily undefine _DEBUG when Python.h is #included.

If you want the extra runtime checks available with the debugging version of the library, #define BOOST_DEBUG_PYTHON to re-enable library forcing, and link with the DebugPython version of boost_python.lib. You'll need to get the debugging version of the Python executable (python_d.exe) and DLL (python20_d.dll or python15_d.dll). The Python sources include project files for building these. If you download them, change the name of the top-level directory to src, and install it under c:\tools\python, the workspace supplied by Boost.Python will be able to use it without modification. Just open c:\tools\python\src\pcbuild\pcbuild.dsw and invoke "build all" to generate all the debugging targets.

If you do not #define BOOST_DEBUG_PYTHON, be sure that any source files #include <boost/python/detail/wrap_python.hpp> instead of the usual Python.h, or you will have link incompatibilities.


If your platform isn't directly supported, you can build a static library from the following source files (in the Boost subdirectory libs/python/src), or compile them directly and link the resulting objects into your extension module:
Next: Wrapping Enums Previous: A Peek Under the Hood Up: Top

© Copyright David Abrahams 2000. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

Updated: Apr 17, 2001 (R.W. Grosse-Kunstleve)