Re: Access to C++ dlls from Python
"Diez B. Roggisch" <[email protected]> Fri, 29 Oct 2010 16:47:38 +0200
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Please reply to the mailing-list, not me personally. Am 29.10.2010 um 16:16 schrieb bifferos: > > I thought the wrappers were more for the case where you had the source > for the wrapped functions. I've still got to find an load the DLL, > then > pass object pointers into my wrapper code. Also, the wrapper > requires that I have the relevant vc2003 license (my dll was compiled > with that). Actually, more to the point, I'm not sure you can even > buy > the vs2003 compiler, although you can get the later ones, and the ABI > may well be the same. > > For information, I have the headers for the classes, the DLL > consists of > a 'factory' function which returns a void ptr to an object instance. > The interface I'm using is pure virtual, so it becomes a little > simpler > in the memory layout. > > I'd very much like to have any references to these 'attempts' you're > speaking of. I'd take non-working code over nothing at this stage. None of this is relevant AFAIK. Wrapper-generators also only need headers and of course the library itself. Then the extension will be a DLL of it's own, loading/linking to the original C++-DLL. The compiler-question is potentially an issue if there is a mismatch between the MSVCRT-variants Python and your DLL use, but that's a problem under all circumstances. The discussions have taken place on this list, please google them. I can't comment on the state of affairs there, but in all honesty: creating a patched + proprietary version of ctypes is *way* more effort that to create C++ extension. ctypes-C++ support would only be useful if it would work the same way as ctypes does - seamless, without the need to invoke a compiler. It doesn't, and it seems to be a problem that's pretty hard. If you don't want to go down the C++-wrapper route, you might consider wrtiting a simple C-API-wrapper that can be loaded using ctypes. That however depends how high the trade-off between wrapping by hand and generating is. The richer the C++-interface, the more you should check out SIP. Diez ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev