[Rcpp-devel] [RcppExamples] -- would someone share the makefile?

Johannes Egner johannes.egner at gmail.com
Sat Aug 21 22:30:47 CEST 2010


Dirk, Romain,

thanks for your replies.

I suspect I should have been more verbose. Here's what I was trying to do:

(1) The convolve function is the standard example for using .Call or .C; and
it is easy (using MinGW or even cl.exe in MSVC) to produce a DLL that one
can call from R (possibly modulo name mangling): 5 minutes, tops. Most
importantly: up to the point where R loads the DLL, I know precisely what
was going on.

(2) This is a reassuring result, and I want to achieve the same thing with
Rcpp. Ok, let's read your article "Rcpp: Seamless R and C++ integration".
Page 2 has the code. I didn't expect it to work, but nonetheless tried MinGW
(because you were pretty clear on MSVC...) on this simple example. (Let's
forget about a header file that may be necessary to expose the function, or
any trap related to calling conventions for the moment.)

(3) MinGW needs the header files from Rcpp (0.8.5, WinBinary -- I don't
think 0.7.1 is any different, although I should have used this). Rcpp.h is
needed, which I find in Rcpp/include and place it in the root of the
"project folder" (a folder just containing the cpp-file). Ok, this isn't
working -- it needs to be #include "Rcpp.h", and not #include <Rcpp.h>,
because I have no environment variables set for MinGW, and the compiler
apparently does not look at the root of the folder (which MSVC would do).

(4) Having changed that, MinGW wants to see RcppCommon.h (ok, my mistake --
I should have had a look into Rcpp.h!). Same bracket vs quote thing. Next
are various header files from Rcpp/include/Rcpp and Rcpp/classic -- each
time with the same bracket/quote issue.

(5) I must be on the wrong track -- changing the header files cannot be the
intented solution. I now suspect a makefile could be the solution -- maybe
it defines where to look for all those header files. (Hoping it also might
give me some indication how I can later compile code from many different
files.) Because I don't know (yet) how to make such a makefile, I have
looked into RcppExamples, and then written my first mail to the list.

Now using Rcpp.package.skeleton is indeed a step forward -- it passes R CMD,
becomes a tarball, and I can build a zip file with the DLL in it. (Which
correctly exposes the function rcpp_hello_world). It seems R CMD build
miraculously knows how to feed the right arguments to the compiler (and lets
it know where all the headers are). As convenient as this is, it is a bit
too opaque for me. I suspect I'd struggle to develop "realistic code"
(several files, links to static/dynamic libraries,...) just relying on R's
package building mechanism.

Long story short: something as in (1), i.e. a simple, but %working% piece of
code where all "mechanics" (dependencies, compiler arguments, etc) are
transparent is what I'm after. I would imagine that this could be done by
explaining what happens behind the stages when R CMD build is called, and
that these mechanics are best scaled to code projects of realistic sizes by
the mentioned makefiles -- but I might of course be wrong.

Best wishes, Jo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20100821/3796743a/attachment-0001.htm>


More information about the Rcpp-devel mailing list