Re: How to wrap a existing DLL to a python module?

"Bruce Who" <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding,gmane.comp.programming.swig,gmane.comp.python.c++
Message-ID <[email protected]>
Hi,

Another question, what i do now is wrap all functions in DLL again like this:

// this is header file for DLL
void func(void)
{
    ...
}

// this is my .cpp file for swig
#pragma comment(lib, "TEVlib.lib")

void _func(void)
{
    func() // this is the func of DLL
}

// this is .i file
%inline{
extern void _func(void);
%}

I just wonder if it is possible that we can generate a .py file
directly from the header file of DLL with all functions exposed? I
think that can save a lot of time. I have tried without success.

On 4/27/07, Bruce Who <[email protected]> wrote:
> Hi, all
>
> I have a DLL and related .lib and .h files provided by 3rd party, and
> I want to make a python extension module from this dll I tried swig
> but failed.
>
> At first , I just used this command:
>
> swig -python -module TEVLib TEVLib.h
>
> I got a TEVLib.py file, but it did not work of course. So I tried
> another method: I wrote TEV.c and TEV.i, this TEV.c just wrappered all
> functions from TEVLib and included all necessary .h files and also
> included this statement
>
> #pragma comment(lib, "TEVLib.lib")
>
> Then I compiled all of these and got TEVLib.py and _TEVLib.pyd, but
> when I tried to import it, error occured, it's said something like
> that the DLL could not be imported.
>
> I know that we can use ctypes to call functions in dll, but I just get
> bored with defining function prototypes with CFUNCTYPE. That's why I
> choose swig.
>
> As a newbie, I just do not know why it doesnot work. Could somebody
> help me out?Thanks in advance.
>

Bruce

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.