[Rd] Call C code from R

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Sep 17 09:08:25 CEST 2007


On Mon, 17 Sep 2007, ????? ?. ???????  wrote:

> Hello, All!
>
> I'm new for R-devel list. And I'd like to ask some questions,
> maybe they will be stuped for the most part of members of the
> list.
> I need to call function which is written in C++ from R.

Your subject line says C ....

> My questions are:
> 1. How should I include libraries (for example, iomanip,
> sstream, iostream)?
> 2. Can I use namespace?

What you link into R is a shared object aka DLL.  If you use the 
documented ways (e.g. R CMD CHLIB) to make this, it will be linked against 
the platform's standard C++ libraries.  There are lots of examples of C++ 
code in CRAN packages doing this.

The use of iostream is discussed in 'Writing R Extensions'.

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list