Error when compiling Rcpp code in an R package using RStudio

c++, r, rcpp

Solution

It is hard to say without having the package available. I guess you miss:

LinkingTo: Rcpp

in your DESCRIPTION file.

Problem

I am using Rstudio to create a package, and exploring the use of the Rcpp package to gain access to C++ code, however, when trying to build the package, and error is being thrown as follows: `fatal error: Rcpp.h: No such file or directory` Inline C++ code compiles fine, its only when considering standalone C++ files in the `src` folder, obviously referring to the `#include <Rcpp.h>` directive at the head of the `.cpp` file. I think it may have something to do with environment variables, does anyone know what the correct configuration is and how to fix for Rstudio operating in an Ubuntu 12.04 LTS environment? The commands `sourceCpp('./src/xyz.cpp')` execute as to be expected, the error is being thrown when `Build and Reload` is executed from within the RStudio IDE.

Original source