[Rcpp-devel] linking external libraries in a package
baptiste.auguie at gmail.com
Wed Jan 1 20:30:35 CET 2014
Hi list, and happy new year,
This is a follow-up to a previous query I made on Stack Overflow,
where my goal is to use an existing library for numerical integration
together with my existing functions using RcppArmadillo.
I've since taken a different perspective: I will call directly the original
C routine and ship it with my package. With helpful guidance from Conrad
Sanderson I managed to sort out the c/c++ side of things. I now have a
stand-alone proof-of-principle code to use the cubature library for
numerical integration, with an integrand based on Armadillo objects (and
some glue between the two),
The command I'm using to create an executable is
g++ -DHCUBATURE -o minimal hcubature.c minimal.c -lm -I /usr/local/include
-O2 -larmadillo -framework Accelerate
where hcubature.c and associated header files come from cubature (
The last piece I'm missing is how to compile such source files in a package
with the correct flags; my understanding is that most of these flags can be
taken care of with a suitable Makevars file. I currently have the following,
PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" )
$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
but I don't see how to link hcubature.c together with another source file.
Do I need a complete Makefile to specify this sort of command? I have zero
experience in these matters of compilation, I'd appreciate some guidance or
simple examples to follow.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel