Le 27/05/10 05:07, Vinh Nguyen a écrit :
On Wed, May 26, 2010 at 6:31 PM, Davor Cubranic<[email protected]> wrote:
On 2010-05-26, at 4:08 PM, Vinh Nguyen wrote:
Also, I didn't include BLAS or LAPACK linking -- still don't know how
to get the compilation flags easily. I read the skeleton stuff but I
don't understand (sorry).
Just put in your package's 'src' directory the Makevars file that's generated
by RcppArmadillo's package.skeleton function. This is what it looks like on my
machine:
PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS)
$(BLAS_LIBS) $(FLIBS)
How do you compile the code, by the way? It sounds like you do it by hand. Why
not let R do it? With the above Makevars and the correct 'Depends' line in your
package description (again, see the skeleton), you won't have to muck about
with compiler switches and lookup paths, and everything should 'just work'.
Davor
Yes, I'm doing it by hand since I'm still coding. I compile after
some progress to make sure everything is OK.
It is not much longer to compile a package is it ?
Let's say I place the my code in in /src. Do I HAVE to turn this into
a package in order to compile? Or is there a way to compile from
here. Sorry I'm new at this approach.
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.
Vinh
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/cork4b : highlight 0.1-8
|- http://bit.ly/bklUXt : RcppArmadillo 0.2.1
`- http://bit.ly/936ck2 : Rcpp 0.8.0
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel