[Pyrex] Creating a DLL with Pyrex.

Blake Winton bwinton at latte.ca
Tue Nov 9 02:12:05 CET 2004


On Tue, Nov 09, 2004 at 01:42:33PM +1300, Greg Ewing wrote:
> Blake Winton wrote:
> >My research indicates that I need to wrap the library with another
> >C-based wrapper
> More precisely, you need a C++ wrapper that exposes a C-callable
> interface.

Okay, that's what I figured.  It's going to be a lot of work, but at
least it's fairly clear as to what I need to do.  Pity that it can't be
done automagically.

> >Anyways, a sample C++ function definition would be
> >long SyncRegisterConduit      (CONDHANDLE &) 
> >And I've translated it into C as:
> >long CSyncRegisterConduit      (CONDHANDLE *) ;
> You'll need to declare it as
>   extern "C" long CSyncRegisterConduit(CONDHANDLE *);
> so that the C++ compiler will make it callable
> from C.

I forgot to include the "#ifdef __cplusplus/extern "C" {/#endif" lines
from the top and bottom of my header file.  (I've done it that way so
that I can also include the file from within my PyRex code.

The other thing I was wondering about was naming.  Since I'm including
both the C++ library and the C wrapper header files in my C++ wrapper,
do I have to give the functions different names, i.e.
SyncRegisterConduit and CSyncRegisterConduit?  Does anyone have a
recommendation for a good naming scheme?

> >And then my implementation would look like:
> >long CSyncRegisterConduit( CONDHANDLE* p1 ) {
> >    return SyncRegisterConduit( *p1 );
> >}
> That looks right, I think.

Okay.  It seems to compile, but it hangs when I run it.  I guess I'll
track the problem down further, now that I know I'm on the right track.

As a side question, do any of you know of anything similar to py2exe for
pyrex?  Uh, not the create-an-exe part of it, but rather the dependancy
tracking part of it.  Specifically, I'ld like to gather up all the dlls
that my pyrex code references (including python 2.x.dll), so that I can
write an installer to put them on the client machine.

Thanks,
Blake.




More information about the Pyrex mailing list