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

Michael Hannon jm_hannon at yahoo.com
Tue May 22 10:04:31 CEST 2012


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*, bool)
>
> You are not telling g++ where to find the R libraries that you need to
> link with.
>
> I've a similar basic RInside example and I've got a comment in the
> header that says compile it with this:
>
> g++ -I/usr/local/lib/R/site-library/Rcpp/include
> -I/usr/local/lib/R/site-library/RInside/include -I/usr/share/R/include
> -L/usr/lib64/R/lib -lR -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp
> -L/usr/local/lib/R/site-library/RInside/lib -lRInside
> -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -lRInside
> -Wl,-rpath,/usr/local/lib/R/site-library/RInside/lib main.cpp
>
>
> You may have to adjust the paths (I'm on ubuntu 10.04, and I think
> default locations for all R packages), but it gives you an idea of what
> you're missing.

Thanks, Darren.  I think that must be the issue.  I'll try adding the
additional include/library directories later today.

For the record, it occurred to me that I didn't include any R, Rcpp, or
RInside information in my original post.  I've appended it below.

-- Mike


$ R --vanilla

R version 2.15.0 (2012-03-30)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-redhat-linux-gnu (64-bit)

> library(help=Rcpp)
[...]
Package:            Rcpp
Title:              Seamless R and C++ Integration
Version:            0.9.9

> library(help=RInside)
[...]
Package:            RInside
Title:              C++ classes to embed R in C++ applications
Version:            0.2.6


More information about the Rcpp-devel mailing list