[Rcpp-devel] Package Rcpp: Question conerning source code of cpp files and related question

Martin Spindler spindler at mea.mpisoc.mpg.de
Tue Sep 30 14:41:31 CEST 2014

Dear all,
I am trying to use Rcpp to write some files in C++ for use in R.
Below is an example for a cpp-file (crossp.cpp). Then I use 
 >sourceCpp("crossp.cpp") in R and the corresponding function is 
availabe in R.
Now I have to question related to this worklfow:
1) Is there a way to see the source file of the "final" cpp-file? (I 
mean is it possible to see how the //-lines are replaced and what 
soureCpp does?)
2) (Connected with the first question) Up to now, I am working in R 
Studio, but I would  prefer an IDE (e.g. NetBeans IDE). But when I 
compile the cpp-file there,  the following message shows up:
In file included from 
                  from crossp.cpp:1:
fatal error: RcppArmadilloLapack.h: No such file or directory
    #include <RcppArmadilloLapack.h>
Is there an way to compile the file without sourCpp but in an IDE? What 
do I have to change?
As I am starting to work with Rcpp my question might sound silly, but 
any help and comments are highly welcome.
Thank you very much for your help in advance!
#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
using namespace Rcpp;
using namespace arma;
NumericMatrix crossp3(NumericMatrix Xr) {
   int n = Xr.nrow(), k = Xr.ncol();
   arma::mat X(Xr.begin(), n, k, false);
   arma::mat XXt = X.t()*X;
   return Rcpp::wrap(XXt);

Dr. Martin Spindler
Senior Researcher
Max Planck Society
Munich Center for the Economics of Aging
Amalienstr. 33
80799 Munich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140930/de9f31e5/attachment.html>

More information about the Rcpp-devel mailing list