[Rcpp-devel] basic usage help

Dirk Eddelbuettel edd at debian.org
Thu May 27 17:13:28 CEST 2010


On 27 May 2010 at 08:05, Vinh Nguyen wrote:
| On Wed, May 26, 2010 at 11:33 PM, Romain Francois
| <romain at r-enthusiasts.com> wrote:
| > If you don't want to use what R and Rcpp provides for you, you can emulate
| > this by using this Makevars :
| >
| > PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" )
| > $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
| > PKG_CXXFLAGS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::CxxFlags()" )
| > $(shell Rscript -e "cat( '-I', system.file('include', package =
| > 'RcppArmadillo'), sep = '' )" )
| >
| >
| > The PKG_LIBS line is the same that the one that gets generated  by
| > RcppArmadillo.package.skeleton.
| >
| > The PKG_CXXFLAGS line pulls in the include path of Rcpp and RcppArmadillo.
| >
| > Just save this as a "Makevars" in the directory where your cpp files are,
| > and run:
| >
| > R CMD SHLIB *cpp -o mylib.so
| >
| >
| > I will add a RcppArmadillo:::CxxFlags() for consistency between Rcpp and
| > RcppArmadillo.
| >
| > Romain
| 
| Thanks Romain.  This is what I'm used to while working with compiled code for R.

Two cautious words of advice:  Don't.   

I did that too (which is how you copied it from the HPC Tutorial notes) but
using things like inline is just so much easier.  Now, it's a little tricky
with RcppArmadillo and the ordering of the header files but that's why we
gave you the corresponding RcppArmadillo.package.skeleton()

-- 
  Regards, Dirk


More information about the Rcpp-devel mailing list