Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Does Boost.Python work with Mac OS X?

It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler:

gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1493)

Under 10.2.8 get the August 2003 gcc update (free at Under 10.3 get the Xcode Tools v1.0 (also free).

Python 2.3 is required. The Python that ships with 10.3 is fine. Under 10.2.8 use these commands to install Python as a framework:

./configure --enable-framework
make frameworkinstall

The last command requires root privileges because the target directory is /Library/Frameworks/Python.framework/Versions/2.3. However, the installation does not interfere with the Python version that ships with 10.2.8.

It is also crucial to increase the stacksize before starting compilations, e.g.:

limit stacksize 8192k

If the stacksize is too small the build might crash with internal compiler errors.

Sometimes Apple's compiler exhibits a bug by printing an error like the following while compiling a boost::python::class_<your_type> template instantiation:

.../inheritance.hpp:44: error: cannot
  dynamic_cast `p' (of type `struct cctbx::boost_python::<unnamed>::add_pair*
  ') to type `void*' (source type is not polymorphic)

We do not know a general workaround, but if the definition of your_type can be modified the following was found to work in all cases encountered so far:

struct your_type
  // before defining any member data
#if defined(__MACH__) &amp;&amp; defined(__APPLE_CC__) &amp;&amp; __APPLE_CC__ == 1493
  bool dummy_;
  // now your member data, e.g.
  double x;
  int j;
  // etc.