<div dir="ltr">Hi list, and happy new year,<div><br></div><div>This is a follow-up to a previous query I made on Stack Overflow, </div><div><a href="http://stackoverflow.com/questions/20474303/using-c-function-from-other-package-in-rcpp" target="_blank">http://stackoverflow.com/questions/20474303/using-c-function-from-other-package-in-rcpp</a><br>

</div><div>where my goal is to use an existing library for numerical integration together with my existing functions using RcppArmadillo.</div><div><br></div><div>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),</div>
<div><a href="https://github.com/baptiste/cubature/blob/master/minimal.c">https://github.com/baptiste/cubature/blob/master/minimal.c</a></div><div> </div><div>The command I'm using to create an executable is</div><div>
<br></div><div>g++ -DHCUBATURE -o minimal hcubature.c minimal.c -lm -I /usr/local/include -O2  -larmadillo -framework Accelerate</div>
<div><br></div><div>where hcubature.c and associated header files come from cubature ( <a href="http://ab-initio.mit.edu/wiki/index.php/Cubature">http://ab-initio.mit.edu/wiki/index.php/Cubature</a> ). </div><div><br></div>
<div>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,</div>
<div><br></div><div>PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)<br>
</div><div><br></div><div>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. </div>
<div><br></div><div>Best regards,</div><div><br></div><div>baptiste</div><div><br></div><div><br></div></div>