[Rcpp-devel] basic usage help

Vinh Nguyen vinhdizzo at gmail.com
Thu May 27 17:05:19 CEST 2010


On Wed, May 26, 2010 at 11:33 PM, Romain Francois
<romain at r-enthusiasts.com> wrote:
> You don't have to, but it makes your life easier. Now that we use LinkingTo:
> Rcpp, RcppArmadillo it makes our Makevars smaller and more robust. R figures
> out on its own where to find Rcpp and RcppArmadillo include paths.
>
> 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.


More information about the Rcpp-devel mailing list