[Rd] How difficult is it to wrap a large C++ library with R?

Bo Peng ben.bob at gmail.com
Tue Jul 5 05:22:02 CEST 2005


> SWIG is a very nice idea. ...

SWIG is a wonderful tool that makes wrapping C++ code super-easy. I
can write pure C++ code and even test them by writing a main()
function. Then, using a simple interface file, all my  C++ classes
becomes Python (shadow) classes like magic. It will take much more
time to develop simuPOP if I had to modify interface files manually
for every change to the  C++ classes.

> I hope to have a prototype of a general mechanism for generating
> bindings  to other code for R sometime over the summer.
> It has been hatching for some time and it is primarily a matter of
> getting the time to implement the existing ideas.

Since you already know how to wrap C++ classes to R classes, maybe it
is a good idea to ask SWIG developers how to use SWIG to bridge them.
After all, SWIG has a mature set of tools to parse C++ code and
generate interfaces to more than a dozen scripting languages.

Personally, if I have to write interfaces manually for my 40+ classes
and a lot more functions, I would rather devote time in adding R
support for SWIG.

Thanks.
Bo



More information about the R-devel mailing list