Getting SWIG to work with C++/Python
Boudewijn Rempt
boud at rempt.xs4all.nl
Sat Jan 8 02:26:32 EST 2000
Jason Maskell <backov at nospam.csolve.net> wrote:
> Well, I bit the bullet and reinstalled VC5, and got SWIG to compile. Now, I
> try "swig -c++ -python interf~1.cpp" and it chokes, hard. I try it with the
> h, same thing.. I've tried variations of that, and I keep getting loads of
> syntax errors, etc. Did it compile wrong? Is there some hidden syntax I
> should be using? The other possibility is that since the files I'm swigging
> are Borland C++ and SWIG itself was compiled with VC++.. But I can't see
> that being a problem.
I thought I'd just mention sip, which is a small swig especially
for C++ - Phil Thompson, the author, developed it for the Qt and
KDE bindings - but its scope is wider than that:
Some Background When I started to develop these bindings I (like
everybody else) had a look at SWIG. I came to the conclusion that,
while the concept is excellent, the C++ support isn't really up to it.
I then wrote SIP (so called because it is a small SWIG) which does
a similar job but is specifically designed for generating Python
bindings for C++ class libraries.
SIP works in a similar way to SWIG in that it generates compilable C++
code from a set of specification files. The format of a specification
is similar (but not identical) to a C++ header file. SIP also includes
a run-time support library for the generated code - so you need a
copy of SIP even if you are not generating your own code.
One of my design goals was to make all the features of underlying
class library available to the Python programmer in exactly the same
way as they would be available to the C++ programmer - this has (for
the most part) been achieved.
You can find it at: http://www.river-bank.demon.co.uk/software/
--
Boudewijn Rempt | http://www.xs4all.nl/~bsarempt
More information about the Python-list
mailing list