Boost Python class won't import

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost Python class won't import

Kevin Hughes
Hello,

I am trying to wrap a simple class that runs some image processing routines. I would like them to be script-able from python.

I am not trying to pass complicated types, in fact almost all the functions take and return no arguments. Here is my wrapper code (generated with pyplusplus partially):


#include "boost/python.hpp"

#include "eventDetector.h"

namespace bp = boost::python;

BOOST_PYTHON_MODULE(pyplusplus){

    { //::eventDetector
        typedef bp::class_< eventDetector > eventDetector_exposer_t;
        eventDetector_exposer_t eventDetector_exposer = eventDetector_exposer_t( "eventDetector", bp::init< params & >(( bp::arg("op") )) );
        bp::scope eventDetector_scope( eventDetector_exposer );
        bp::implicitly_convertible< params &, eventDetector >();
        { //::eventDetector::detect
        
            typedef void ( ::eventDetector::*detect_function_type )(  ) ;
            
            eventDetector_exposer.def( 
                "detect"
                , detect_function_type( &::eventDetector::detect ) );
        
        }
        { //::eventDetector::init
        
            typedef void ( ::eventDetector::*init_function_type )(  ) ;
            
            eventDetector_exposer.def( 
                "init"
                , init_function_type( &::eventDetector::init ) );
        
        }
        { //::eventDetector::load
        
            typedef void ( ::eventDetector::*load_function_type )(  ) ;
            
            eventDetector_exposer.def( 
                "load"
                , load_function_type( &::eventDetector::load ) );
        
        }
        { //::eventDetector::save
        
            typedef void ( ::eventDetector::*save_function_type )(  ) ;
            
            eventDetector_exposer.def( 
                "save"
                , save_function_type( &::eventDetector::save ) );
        
        }
        { //::eventDetector::setGridSize
        
            typedef void ( ::eventDetector::*setGridSize_function_type )( int,int ) ;
            
            eventDetector_exposer.def( 
                "setGridSize"
                , setGridSize_function_type( &::eventDetector::setGridSize )
                , ( bp::arg("x"), bp::arg("y") ) );
        
        }
        { //::eventDetector::setVideoCapture
        
            typedef bool ( ::eventDetector::*setVideoCapture_function_type )( ::std::string ) ;
            
            eventDetector_exposer.def( 
                "setVideoCapture"
                , setVideoCapture_function_type( &::eventDetector::setVideoCapture )
                , ( bp::arg("filename") ) );
        
        }
        { //::eventDetector::setVideoCapture
        
            typedef bool ( ::eventDetector::*setVideoCapture_function_type )( int ) ;
            
            eventDetector_exposer.def( 
                "setVideoCapture"
                , setVideoCapture_function_type( &::eventDetector::setVideoCapture )
                , ( bp::arg("cam") ) );
        
        }
        { //::eventDetector::train
        
            typedef void ( ::eventDetector::*train_function_type )(  ) ;
            
            eventDetector_exposer.def( 
                "train"
                , train_function_type( &::eventDetector::train ) );
        
        }
    }
    
    bp::class_< params >( "params" )    
        ... large list of simple params...;
    
}


It builds fine using bjam but when I import into python I get an error message: libEventDetector.so: undefined symbol: _ZN13eventDetector4loadEv.

I am really not very good with boost::python and I don't really know what to do. Help is appreciated, thank you!

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig
Reply | Threaded
Open this post in threaded view
|

Re: Boost Python class won't import

Stefan Seefeld-2
On 09/23/2011 04:34 PM, Kevin Hughes wrote:
>
> It builds fine using bjam but when I import into python I get an error
> message: libEventDetector.so: undefined symbol: _ZN13eventDetector4loadEv.
>
> I am really not very good with boost::python and I don't really know
> what to do. Help is appreciated, thank you!

The problem is unrelated to boost.python. It appears you are not linking
all the symbols that are required. Try to find where the
"_ZN13eventDetector4loadEv" symbol (in C++: "eventDetector::load()") is
defined, and what object file or library you need to link to when
building your extension module.

HTH,
        Stefan

--

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/cplusplus-sig