Hi,
Sorry for the newbie question but I wish to access values contained in an R file (foo.r) using C++ (source code in bar.cpp). I am using R (3.0.1) via RStudio (0.98.501) under Ubuntu 13.10. >>>> The content of foo.r is: someNumber <<- 42 stooges <<- c("moe", "larry", "curly") >>>> The content of bar.cpp is: #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] int checkEnv() { // access the global env. Environment env = Environment::global_env(); CharacterVector v = env["stooges"]; Rcout << "Stooge Nb 2 is: " << v[1] << std::endl; return env["someNumber"]; } int main(){ checkEnv(); return 0; } I have run Rcpp::sourceCpp('foo.r') from within RStudio. Question: How do I compile and run the C++ file from within RStudio? If I try to compile it outside RStudio using g++ bar.cpp -o bar, the header file Rcpp.h is not recognised. No doubt this has been asked before but I cannot find the answer and I would be most grateful for assistance. Thanks.
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel