Using C++ and ctypes together: a vast conspiracy? ;)

A. Cavallo a.cavallo at mailsnare.com
Wed Jun 3 00:58:34 CEST 2009


Mmmm, 
not really a conspiracy but it is not that trivial....

In wrapping c++ you might find useful the commands nm with c++filt
although they work under linux there is the same pair for every platform 
(under windows I remember there is objdump): they should only you need to wrap 
a c++ library.

I've been wrapping in the past c++ using boost and it was trivial although I 
haven't tried enough to break it.

swig, in older versions, is really bad: I can't comment on newer versions but 
I'd have a look to the generated code before using it.

sip it looks quite difficult to use, but is well maintained.

If you have a moderate control on the library design the ctype is the best 
approach IMHO.

Regards,
Antonio



On Tuesday 02 June 2009 21:50:24 Joseph Garvin wrote:
> So I was curious whether it's possible to use the ctypes module with
> C++ and if so how difficult it is. I figure in principal it's possible
> if ctypes knows about each compiler's name mangling scheme. So I
> searched for "ctypes c++" on Google.
>
> The third link will be "Using ctypes to Wrap C++ Libraries". If you
> follow the link, it's broken. If you view the cache of the link, it's
> someone pointing to another blog, retrograde-orbit.blogspot.com,
> saying they discovered a way to do it easily. If you follow that link,
> you get taken a page does not exist error.
>
> Clearly there's some way to use ctypes with C++ and there's a vast
> conspiracy preventing it from reaching the masses ;) What's even
> stranger is that this link, despite being broken, has seemingly been
> near the top of google's results for these terms for a couple weeks
> (that's when I last tried), as if there were some underground group of
> rebels trying to hint the truth to us... ;)
>
> More seriously -- how difficult is it to use ctypes instead of saying,
> boost::python, and why isn't this in a FAQ somewhere? ;)




More information about the Python-list mailing list