[Rcpp-devel] basic usage help

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

My next question is: if I have both .c and .cpp files in ./src/ is
made from RcppArmadillo's skeleton function is OK right?  I never
understood the stuff about libraries and headers so I never know
what's going on under the hood.  I just tried building a package with
both kinds of files and the package built without an error.


On Thu, May 27, 2010 at 8:05 AM, Vinh Nguyen <vinhdizzo at gmail.com> wrote:
> 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()" )
>> 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