I have a library and some head files, no c++ source code, I want to use it with python. I tried py++, but gccxml report error. I tried swig, but some many "undefined symbol" errors. Are there some smart tools can do such things automatically?
You could try using boost python
You'd need to create a simple wrapper dll that links to your original library, containing code similar to this (assuming you wanted to export a class called LibraryClass with 2 functions, foo & bar)
#include <librarytowrap.h>
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(Library)
{
class_<LibraryClass>("LibraryClass")
.def("foo", &LibraryClass::foo)
.def("bar", &LibraryClass::bar)
;
}
You might be able to use the automatic code generator to read the C++ definitions in the header files and do the hard work for you, but according to the boost python page this is no longer maintained, so I'm unsure how well it works.
Can you not just use the python ctypes package?
See this tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With