[R] using C++ with R?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Sat Sep 18 06:31:35 CEST 1999


On Fri, 17 Sep 1999, Matthew Wiener wrote:

> Is it possible to compile C++ code for use with R?  Based on a few
> experiments with simple C++ programs, the answer appears to be no.  Has
> anyone managed this?

Yes.  There is a tiny example in the draft R programming manual (not yet
available). There are two issues I know of:

(i) Use extern "C" { } around things you want to export symbols from to R.
(ii) Link the shared library/DLL with the C++ compiler (e.g. g++)
not ld.

The issues are pretty generic, and apply also to S-PLUS, for example,
and there there are plenty of successful examples.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list