From ripley at stats.ox.ac.uk  Mon Sep 17 09:08:25 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 17 Sep 2007 08:08:25 +0100 (BST)
Subject: [Rd] Call C code from R
In-Reply-To: <web-11654315@hermes.nsu.ru>
References: <web-11654315@hermes.nsu.ru>
Message-ID: <Pine.LNX.4.64.0709170801250.21407@gannet.stats.ox.ac.uk>

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



[Rd] Call C code from R
Prof Brian Ripley