I have read some docs from SWIG documentation (related to c++ code), but can't figure out if it is possible to genereate Python extension module in case I have compiled dll (no source code provided) and header file with all functions declared in dll.
If someone has the same problem and solve it, could you provide some useful example?
Thanks in advance.
There's no such a thing like "include header files in a dll file". What you can do is: include header files in a source code file (i.e. *.
If you DO have appropriate . LIB file, and you have exact function prototype, you don't need header. Just declare the functions youself (possibly in your own custom header).
The most common format of a SWIG interface is as follows: %module mymodule %{ #include "myheader. h" %} // Now list ANSI C/C++ declarations int foo; int bar(int x); ... The module name is supplied using the special %module directive.
The Simplified Wrapper and Interface Generator (SWIG) is an open-source software tool used to connect computer programs or libraries written in C or C++ with scripting languages such as Lua, Perl, PHP, Python, R, Ruby, Tcl, and other languages like C#, Java, JavaScript, Go, D, OCaml, Octave, Scilab and Scheme.
Yes, it is possible. SWIG only uses the headers to generate wrapper functions. Here's a simple SWIG file:
%module mymod
%{
#include "myheader.h"
%}
%include "myheader.h"
Then:
swig -python -c++ mymod.i
Then compile and link the generated code as a Python extension DLL. You will also need to link in the .lib for the wrapped DLL.
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