title: Hello world with boost python and python 3.2
body: <p>So I'm trying to interface python 3.2 and c++ using boost python, and have come across many many issues. I've finally gotten it to compile using the 2.7 libraries and it works, but I can't seem to make it work with python 3.2. </p>
  
  <p>Here's the c++ code</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  void say_hello(const char* name) {
      cout &lt;&lt; "Hello " &lt;&lt;  name &lt;&lt; "!\n";
  }
  
  int main(){return 0;}
  
  #include &lt;boost/python/module.hpp&gt;
  #include &lt;boost/python/def.hpp&gt;
  using namespace boost::python;
  
  BOOST_PYTHON_MODULE(hello)
  {
      def("say_hello", say_hello);
  }
  </code></pre>
  
  <p>If I compile it using the 2.7 libraries it works just fine, but when I use the 3.2 libraries I get tons of undefined references from libboost_python.so</p>
  
  <p>Otherwise I wrote a little bit of python to make it work:</p>
  
  <pre><code>from distutils.core import setup
  from distutils.extension import Extension
  
  setup(name="PackageName",
      ext_modules=[
          Extension("hello", ["testBoost.cpp"],
          libraries = ["boost_python"])
      ])
  </code></pre>
  
  <p>and this will create an so using python 3.2 or 2.7 build, but when I open the python 3 interpreter and attempt to import the so it give me the error undefined symbol PyClass_Type from libboost_python.so again. Any ideas? Is boost python compatible with python 3.x?</p>
  
  <p>If the information is useful, here is my attempted compile using 3.2:</p>
  
  <pre><code>   $ g++ testBoost.cpp -I/usr/include/python3.2 -I/usr/local/include/boost/python -lboost_python -lpython3.2mu 
      /tmp/ccdmU1Yu.o: In function `PyInit_hello':
      testBoost.cpp:(.text+0xc2): undefined reference to `boost::python::detail::init_module(PyModuleDef&amp;, void (*)())'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_Size'
      /usr/local/lib/libboost_python.so: undefined reference to `PyFile_FromString'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_Type'
      /usr/local/lib/libboost_python.so: undefined reference to `PyInt_Type'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_FromString'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_FromStringAndSize'
      /usr/local/lib/libboost_python.so: undefined reference to `Py_InitModule4_64'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_FromFormat'
      /usr/local/lib/libboost_python.so: undefined reference to `PyNumber_Divide'
      /usr/local/lib/libboost_python.so: undefined reference to `PyNumber_InPlaceDivide'
      /usr/local/lib/libboost_python.so: undefined reference to `PyInt_AsLong'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_InternFromString'
      /usr/local/lib/libboost_python.so: undefined reference to `PyClass_Type'
      /usr/local/lib/libboost_python.so: undefined reference to `PyString_AsString'
      /usr/local/lib/libboost_python.so: undefined reference to `PyInt_FromLong'
      /usr/local/lib/libboost_python.so: undefined reference to `PyFile_AsFile'
      collect2: ld returned 1 exit status
  </code></pre>
  
  <p>And the error from the python 3 interpreter is</p>
  
  <pre><code>File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ImportError: /usr/local/lib/libboost_python.so.1.47.0: undefined symbol: PyClass_Type
  </code></pre>
  
  <p>Thanks for any help!</p>