[Rcpp-devel] Problem with RInside "hello world" example

Michael Hannon jm_hannon at yahoo.com
Tue May 22 21:51:12 CEST 2012

Dirk Eddelbuettel <edd at debian.org> wrote:

> On 22 May 2012 at 01:04, Michael Hannon wrote:
>| Darren Cook <darren at dcook.org> wrote:
>| >> I've run into a problem with the RInside "hello world" > example.  I can
>| >> not get it to compile on my system.  The first of the many error
>| >> messages is:
>| >>
>| >>     undefined reference to `RInside::RInside(int, char const* const*,
>| >
>| > You are not telling g++ where to find the R libraries that you need to
>| > link with.
>Correct -- the RInside package comes with four example directories.
>And each of these four directories has a Makefile.  The easiest to start with
>   examples/standard/Makefile
>as you can simply drop in a new file 'myhelloworld.cpp' (or any other name
>you choose) into this directory and say 'make myhelloworld' --- and the
>binary 'myhelloworld' will be created for you.
>It does this by querying R via Rscript to learn about
>   headers and libraries for R
>   headers and libraries for Rcpp
>   headers and libraries for RInside
>and all six components are needed for compiling and linking. 
Hmm.  Thanks, Dirk.  That Makefile is downright spooky smart (and worth a
study in its own right).  I was unaware of the "RHOME" option for R and the
"shell" function in GNU make.  Given that I had only one *.cpp file in the
directory, I got the binary to build simply by typing "make", but I did check
that "make <filename>" also appears to work.

-- Mike

More information about the Rcpp-devel mailing list