Boost Python Issue

JDJMSon jdjmson at yahoo.com
Fri Sep 1 00:23:53 CEST 2006


I was wondering if someone here could help me with a problem I'm having
building Python extensions with the Boost.Python library.
Basically, if I have a wrapper class with something like this:

string TestFunc()
{
	return "Hello World";
}

BOOST_PYTHON_MODULE(TestClass)
{
	def("TestFunc",TestFunc);
}


It compiles and I can use it without a problem. However, when I try to
wrap a class with code like this:

class TestClass
{
public:
	TestClass() {};
	~TestClass() {};
	string TestFunction(){return "Hello World";};
};

BOOST_PYTHON_MODULE(TestClass)
{
	class_<TestClass>("TestClass")
		.def("TestFunction",&TestClass.TestFunction)
	;
}


I get the following error:
vc-C++
bin\PythonTest\TestClass.pyd\vc-8_0\debug\threading-multi\TestClass.obj
TestClass.cpp
TestClass.cpp(27) : error C2976: 'boost::python::class_' : too few
template arguments

c:\Development\Boost\boost_1_33_1\boost/python/def_visitor.hpp(14) :
see declaration of 'boost::python::class_'
TestClass.cpp(27) : error C2440: '<function-style-cast>' : cannot
convert from 'const char [10]' to 'boost::python::class_'
        Source or target has incomplete type

I'm using Visual Studio 2005 Express Edition (I get the same error with
2003 Professional), and am using bJam to build the extension.

Does anyone have any idea what's causing this?




More information about the Python-list mailing list