• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Does Boost.Python work with Mac OS X?</title>
5<link rel="stylesheet" href="../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../index.html" title="Boost.Python">
8<link rel="up" href="../faq.html" title="Chapter 5. Frequently Asked Questions (FAQs)">
9<link rel="prev" href="why_doesn_t_my_operator_work.html" title="Why doesn't my *= operator work?">
10<link rel="next" href="how_can_i_find_the_existing_pyob.html" title="How can I find the existing PyObject that holds a C++ object?">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/boost.png"></td></tr></table>
14<hr>
15<div class="spirit-nav">
16<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
17</div>
18<div class="section">
19<div class="titlepage"><div><div><h3 class="title">
20<a name="faq.does_boost_python_work_with_mac_"></a><a class="link" href="does_boost_python_work_with_mac_.html" title="Does Boost.Python work with Mac OS X?">Does Boost.Python
21      work with Mac OS X?</a>
22</h3></div></div></div>
23<p>
24        It is known to work under 10.2.8 and 10.3 using Apple's gcc 3.3 compiler:
25      </p>
26<pre class="programlisting"><span class="identifier">gcc</span> <span class="special">(</span><span class="identifier">GCC</span><span class="special">)</span> <span class="number">3.3</span> <span class="number">20030304</span> <span class="special">(</span><span class="identifier">Apple</span> <span class="identifier">Computer</span><span class="special">,</span> <span class="identifier">Inc</span><span class="special">.</span> <span class="identifier">build</span> <span class="number">1493</span><span class="special">)</span></pre>
27<p>
28        Under 10.2.8 get the August 2003 gcc update (free at <a href="http://connect.apple.com" target="_top">http://connect.apple.com</a>).
29        Under 10.3 get the Xcode Tools v1.0 (also free).
30      </p>
31<p>
32        Python 2.3 is required. The Python that ships with 10.3 is fine. Under 10.2.8
33        use these commands to install Python as a framework:
34      </p>
35<pre class="programlisting"><span class="special">./</span><span class="identifier">configure</span> <span class="special">--</span><span class="identifier">enable</span><span class="special">-</span><span class="identifier">framework</span>
36<span class="identifier">make</span>
37<span class="identifier">make</span> <span class="identifier">frameworkinstall</span></pre>
38<p>
39        The last command requires root privileges because the target directory is
40        <code class="computeroutput"><span class="special">/</span><span class="identifier">Library</span><span class="special">/</span><span class="identifier">Frameworks</span><span class="special">/</span><span class="identifier">Python</span><span class="special">.</span><span class="identifier">framework</span><span class="special">/</span><span class="identifier">Versions</span><span class="special">/</span><span class="number">2.3</span></code>. However,
41        the installation does not interfere with the Python version that ships with
42        10.2.8.
43      </p>
44<p>
45        It is also crucial to increase the <code class="computeroutput"><span class="identifier">stacksize</span></code>
46        before starting compilations, e.g.:
47      </p>
48<pre class="programlisting"><span class="identifier">limit</span> <span class="identifier">stacksize</span> <span class="number">8192</span><span class="identifier">k</span></pre>
49<p>
50        If the <code class="computeroutput"><span class="identifier">stacksize</span></code> is too small
51        the build might crash with internal compiler errors.
52      </p>
53<p>
54        Sometimes Apple's compiler exhibits a bug by printing an error like the following
55        while compiling a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">::</span><span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">your_type</span><span class="special">&gt;</span></code>
56        template instantiation:
57      </p>
58<pre class="programlisting"><span class="special">.../</span><span class="identifier">inheritance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">:</span><span class="number">44</span><span class="special">:</span> <span class="identifier">error</span><span class="special">:</span> <span class="identifier">cannot</span>
59  <span class="keyword">dynamic_cast</span> <span class="error">`</span><span class="identifier">p</span><span class="char">' (of type `struct cctbx::boost_python::&lt;unnamed&gt;::add_pair*
60  '</span><span class="special">)</span> <span class="identifier">to</span> <span class="identifier">type</span> <span class="error">`</span><span class="keyword">void</span><span class="special">*</span><span class="error">'</span> <span class="special">(</span><span class="identifier">source</span> <span class="identifier">type</span> <span class="identifier">is</span> <span class="keyword">not</span> <span class="identifier">polymorphic</span><span class="special">)</span>
61</pre>
62<p>
63        We do not know a general workaround, but if the definition of <code class="computeroutput"><span class="identifier">your_type</span></code> can be modified the following
64        was found to work in all cases encountered so far:
65      </p>
66<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">your_type</span>
67<span class="special">{</span>
68  <span class="comment">// before defining any member data</span>
69<span class="preprocessor">#if</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__MACH__</span><span class="special">)</span> <span class="special">&amp;</span><span class="identifier">amp</span><span class="special">;&amp;</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">defined</span><span class="special">(</span><span class="identifier">__APPLE_CC__</span><span class="special">)</span> <span class="special">&amp;</span><span class="identifier">amp</span><span class="special">;&amp;</span><span class="identifier">amp</span><span class="special">;</span> <span class="identifier">__APPLE_CC__</span> <span class="special">==</span> <span class="number">1493</span>
70  <span class="keyword">bool</span> <span class="identifier">dummy_</span><span class="special">;</span>
71<span class="preprocessor">#endif</span>
72  <span class="comment">// now your member data, e.g.</span>
73  <span class="keyword">double</span> <span class="identifier">x</span><span class="special">;</span>
74  <span class="keyword">int</span> <span class="identifier">j</span><span class="special">;</span>
75  <span class="comment">// etc.</span>
76<span class="special">};</span>
77</pre>
78</div>
79<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
80<td align="left"></td>
81<td align="right"><div class="copyright-footer">Copyright © 2002-2015 David
82      Abrahams, Stefan Seefeld<p>
83        Distributed under the Boost Software License, Version 1.0. (See accompanying
84        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
85      </p>
86</div></td>
87</tr></table>
88<hr>
89<div class="spirit-nav">
90<a accesskey="p" href="why_doesn_t_my_operator_work.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="how_can_i_find_the_existing_pyob.html"><img src="../images/next.png" alt="Next"></a>
91</div>
92</body>
93</html>
94