[C++-sig] Boost Python Question - Multiple Classes and Modules not appearing as attribute

Jon Lederman jonlederman at gmail.com
Thu Sep 8 16:29:12 EDT 2016


Hi,

I am trying to use Boost Python with a set of classes I am compiling into a library.

Call them class A, class B and class C.

If I just have class A and I use:  BOOST_PYTHON_MODULE(A) and my Makefile builds an executable called A.so I am able to see the classes embedded in the module.  
However, if I compile to a different .so name, say D.so, I cannot see any of the classes inside my BOOST_PYTHON_MODULE definition.  For example, if I wrote:

BOOST_PYTHON_MODULE(strategy)
{
	using namespace boost::python;


	class_<OpusEncoderStrategy>("EncoderStrategy", init<const int, const int, const int>())
	.def("setComplexity", &EncoderStrategy::setComplexity)
	.def("getComplexity", &EncoderStrategy::getComplexity);
}


and I compile my code to be in a shared object strategy.so, when I load the class into python, I don’t see the EncoderStrategy class as an attribute of strategy.  I have tried to read the docs re: packages and submodules but am unclear how to use them.  

Ideally, I would like one .so file called strategy.so that encompasses a set of classes.  Is there an example or other documentation that would help me here?

Thanks.

-Jon


More information about the Cplusplus-sig mailing list