<?xml version="1.0" encoding="iso-8859-1"?>
<!-- name="generator" content="pyblosxom/1.3.2 2/13/2006" -->
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
<channel>
<title>Diane's World   </title>
<link>http://woldlab.caltech.edu/~diane/index.cgi</link>
<description>I take the 5th</description>
<language>en</language>
<item>
  <title>Python &amp; Boost</title>
  <link>http://woldlab.caltech.edu/~diane/index.cgi/geek/programming/python-boost-2005-11-18-23-45.html</link>
  <description><![CDATA[

<div class="document">
<blockquote>
<p>I've wanted to try to use python &amp; boost for a while, but their tutorial
depends on using bjam, which has been a pain to try and figure out. And
of course the boost-python developers think that jam is the best thing
ever and don't bother providing any documentation of how to use boost-python
in a more traditional environment.</p>
<p>Here's my stab.</p>
<pre class="literal-block">
/* hello.cxx */
#include &lt;boost/python.hpp&gt;
using namespace boost::python;

char const* greet()
{
  return &quot;hello, world&quot;;
}

BOOST_PYTHON_MODULE(hello)
{
  def(&quot;greet&quot;, greet);
}
</pre>
<p>I compiled it on an amd64 linux box with the following.</p>
<pre class="literal-block">
$ g++ -c -fpic -I/usr/include/python2.3 hello.cxx -o hello.o
$ g++ -shared -fpic -lpython2.3 -lboost_python hello.o -o hello.so
$ python
&gt;&gt;&gt; import hello
&gt;&gt;&gt; print hello.greet()
</pre>
<p>It turns out the -fpic is required for the AMD64 box, and on an x86 box,
is unnecessary. (Though it doesn't hurt to have leave it in).</p>
<p>Would it have been too hard to show the manual way before extolling
the virtues of their build system? Perhaps they were just being lazy
as coming up with a simple build script on windows would probably be
a lot harder than the above.</p>
</blockquote>
</div>

]]></description>
</item>

</channel>
</rss>
