Python Forum

Full Version: Wrapping c/c++ dll
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a piece of hardware with a C/C++ api in the form of a dll, but I'm unsure what the best option is to make that code useable with python.

I experimented a bit with ctypes on a simple dll I wrote, but the library I want to use has around 30+ functions which will likely be a huge hassle to manually wrap and test every single one of them.
SWIG or CPython bindings seem to offer something more automated, but every example I found seems to build from the .cpp source file, which I do not have.

Any recommendations?
(Aug-25-2023, 12:14 PM)Oolongtea Wrote: [ -> ]every example I found seems to build from the .cpp source file, which I do not have.
I think you'll need at least the header files for the interface. You could try pybind11 or PyBindGen perhaps.
I use boost::python for embedded, works really well
caveat, it’s part of boost which is quite big, pybind11 is header only, might be the way to go.