[C++-sig] boost.python errors on Linux

Max Stricker max.stricker at student.tugraz.at
Sat Dec 11 13:29:05 CET 2010


Hi,

i need to expose some C++ methods to python and came accross boost.python.
I installed libboost-python1.42-dev on an Ubuntu machine and tried to work with a
simple program found in the docs:

#include <iostream>

class Foo {
	public:
		void bar() {
			std::cout << "Hello" << std::endl;
		}
};

#include <boost/python.hpp>
#include <Python.h>
using namespace boost::python;

BOOST_PYTHON_MODULE(libboopyclass) {
	boost::python::class_<Foo>("Foo")
		.def("bar", &Foo::bar);
}


I build it using: gcc foo.cpp  -I /usr/include/python2.6 -l python2.6 -l boost_python

I get a huge error list indicating that objects like PyObject or PyTypeObject could not be found,
the detailed output is available here: http://pastebin.com/TyN9dZ09

Has anyone an idea whats going on here? How can I get this minimal example to work?


Regards,
Max



More information about the Cplusplus-sig mailing list