How to use swig with compiled dll and header file only
Asked Answered
D

1

6

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.

Devan answered 6/5, 2015 at 12:20 Comment(0)
E
6

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.

Endlong answered 8/5, 2015 at 17:31 Comment(1)
The same approach works for C# as well. I suppose this will work for other languages too.Boone

© 2022 - 2024 — McMap. All rights reserved.