<div dir="ltr">Hi,<div><br></div><div>Dirk was right, unsurprisingly, all it took was to dump the files in src/ and R takes care of everything during package building (I initially had issues with the PATH for my C compiler, which led me to the wrong conclusion that things weren't so simple). All is magically working now :)</div>
<div><br></div><div>Thanks,</div><div><br></div><div>baptiste</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 1 January 2014 17:33, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On 1 January 2014 at 17:30, baptiste auguie wrote:<br>
| Hi list, and happy new year,<br>
<br>
</div>Thanks, and Happy New Year from here too!<br>
<div class="im"><br>
| The command I'm using to create an executable is<br>
|<br>
| g++ -DHCUBATURE -o minimal hcubature.c minimal.c -lm -I /usr/local/include -O2<br>
|  -larmadillo -framework Accelerate<br>
|<br>
| where hcubature.c and associated header files come from cubature ( http://<br>
| <a href="http://ab-initio.mit.edu/wiki/index.php/Cubature" target="_blank">ab-initio.mit.edu/wiki/index.php/Cubature</a> ). <br>
<br>
</div>Summary: No external depends. No extra headers. No extra libraries.<br>
<br>
(Beyond the Accelerate framework which is OS X specific. I do not know if R<br>
would add this automatically.  If it needs manual intervention, you can<br>
handle this with src/Makevars alone. But that is a different question.)<br>
<div class="im"><br>
| The last piece I'm missing is how to compile such source files in a package<br>
| with the correct flags; my understanding is that most of these flags can be<br>
| taken care of with a suitable Makevars file. I currently have the following,<br>
|<br>
| PKG_LIBS = $(shell $(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()" ) $(LAPACK_LIBS)<br>
| $(BLAS_LIBS) $(FLIBS)<br>
|<br>
| but I don't see how to link hcubature.c together with another source file. Do I<br>
| need a complete Makefile to specify this sort of command? I have zero<br>
| experience in these matters of compilation, I'd appreciate some guidance or<br>
| simple examples to follow. <br>
<br>
</div>Just drop it into src/ and you're done.<br>
<br>
There are 5000+ packages on CRAN, and a "large enough" percentage with<br>
compiled code, and a "still large enough percentage" amonth those which<br>
includes external packages. Just look what others are doing -- eg packages<br>
such as RSQLite include the entire SQLite project (plain C, no external<br>
depends).<br>
<br>
More complicated setups exists too where you first descend into<br>
subdirectories of src/ and build entire libraries first. IIRC the Matrix<br>
package does -- but you don't have to.  One of the earlier Rcpp "clients"<br>
which I helped with a package reorginisation was phylobase, and there we did<br>
just that: copy all the external depends into src/ and have Makevars take<br>
care of it. Which avoids the convoluted need for library building under<br>
different OSs and ARCHs.  As I said: drop into src/ and you're done.<br>
<br>
R actually provides a pretty rich build system. If anything, it is a tad<br>
underdocumented.  But lists such as this one, or expert such as Simon, can<br>
set you straight.<br>
<br>
Let me know if you need more help.  I could fork your repo if you're lost.<br>
<br>
Cheers,  Dirk<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br></div>