[Rd] RInside, rcpp compilation problem

Dirk Eddelbuettel edd at debian.org
Wed Dec 5 05:41:56 CET 2012


On 4 December 2012 at 22:47, Simon Urbanek wrote:
| 
| On Dec 4, 2012, at 10:00 PM, Jeff Goode wrote:
| 
| > I have spent some hours browsing the RInside and rcpp documentation, lots of it; but ... as a programmer of C++ since 1990, on both Windows and Unix ... ( Solaris and Ubuntu, and Mandrake/Mandrivo Linux); I see a minor problem ......  Where is the rcpp.h header file??  
| 
| In the Rcpp package which RInside links to. 

Correct. And Depends: upon.

| Please use rcpp-devel mailing list for such questions (as per request of the authors).

Mostly as a courtesy to readers of r-devel.  And several different folks may
respond via rcpp-devel, not all of whom read here as well.

So redirecting via CC:, please feel free to keep follow-up there (but you
need to be subscribed to post).

| > The below code fails to compile as the RInside.h header file references the rcpp.h header file, which is not included with RInclude download. This is the sample code provided in one of the RInside manuals: 
| > #include <iostream> 
| > 
| > #include <RInside.h>                            // for the embedded R via RInside
| > rcpp::NumericMatrix createMatrix(const int n) {
| >    Rcpp::NumericMatrix M(n,n);
| >    for (int i=0; i<n; i++) {
| >        for (int j=0; j<n; j++) {
| >            M(i,j) = i*10 + j; 
| >        }
| >    }
| >    return(M);
| > } 		 	   		  

You appear to have clipped this from examples/standard/rinside_sample1.cpp

That very directory examples/standard, and its neighbouring directories, each
have

    i)   a Makefile for Linux, OS X, ... and 

    ii)  a Makefile.win for Win*, and

    iii) contributed cmake/ files

all of which do the build.  RInside needs itself, Rcpp and R so a few -I and
-L switches need to set --- which those three alternatives do for you.  

So if you, say, do 'cp rinside_sample1.cpp jeff1.cpp' you can just say 
'make jeff1' and the executable will be built.  That is a feature.  The
Makefile should work for your projects, and the other makefiles in the
neighbouring directories show how to do this with MPI, Qt, Wt, and (in SVN)
Boost. 

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



More information about the R-devel mailing list