visual studio 2005 - How to call c++ program in Python -


i have written simple helloworld class. , write boost python wrapper.and debug code dll.my question how can expose code in python , use greet function.i tried giving path in sys.path.insert. not able greet function. code treid below. help.

#include<boost/python.hpp>  using namespace std; using namespace boost::python; class world {  public:  string msg;  void set(string msg) {     this->msg=msg; }   string greet()  {    return msg;  }  };  boost_python_module(expsoingclasses) { class_<world>("world")     .def("greet", &world::greet)     .def("set", &world::set)      ; } 

at least on system, had rename library file expsoingclasses.dll expsoingclasses.pyd before import in python. once that, should work:

import expsoingclasses retval = expsoingclasses.world() retval.set('hello world') print retval.greet() 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -