How to use swig for compiled dll only and header file only

I have read several docs from the SWIG documentation (related to C ++ code), but cannot figure out if it is possible to generate a Python extension module in case I compiled a dll (no source code) and a header file with all the functions declared in the dll.
If anyone has the same problem and solve it, can you provide any useful example?
Thanks in advance.

+3


source to share


1 answer


Yes it is possible. SWIG only uses headers to create 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.

+4


source







All Articles