[Rcpp-devel] Question on 5.6 Interfacing C++ code

Dirk Eddelbuettel edd at debian.org
Wed Apr 20 16:18:29 CEST 2011


Hi Sean,

Steve had the right hunch:  Is this a question for 

    r-devel,  	    	ie R in general, or for 

    rcpp-devel, 	ie R with Rcpp  ?


On 20 April 2011 at 09:49, Sean Robert McGuffee wrote:
| Hi, I have a quick couple of questions about some of the documentation on the
| web page:
| http://cran.r-project.org/doc/manuals/R-exts.html#
| Linking-GUIs-and-other-front_002dends-to-R
| under the heading:
| 5.6 Interfacing C++ code
| 
| Question 1:
| If I?m at a terminal, I can type the instructions they suggest:
| R CMD SHLIB X.cc X_main.cc
| If I wanted a package to do this, how would I tell the package to do that same
| thing?

Place the source files into the top-level directory src/ of the package. 

| Would I use the same command and just include it in a file somewhere in the
| package?
| If so, which file?

'R CMD build' and 'R CMD INSTALL' and ... all take care of it.
 
| Question 2:
| dyn.load(paste("X", .Platform$dynlib.ext, sep = ""))
| 
| Where does .Platform$dynlib.ext come from?
| What does it mean?

R knows that that Windoze uses .dll and .a, Linux uses .so and .a, OS X uses
.dynlib.  It swaps the correct extension based on the OS it is being run on.

| What do it?s components .Platform and $dynlib and .ext mean?

Maybe the help file for .Platform is of interest?

I think you are being somewhat off-topic here and abusing the high
signal-to-noise ration of this list.  The r-devel is list of very high
quality too and has a wider readership, so maybe you should post non-Rcpp
questions there?

I also find learning by example instructive. There are 2946 packages on
CRAN, of which 980 contain a src/ directory.  That makes for 980 examples you
could look at---some are small, some are big, some use C, some use C++, ...  
You should be able to find a few close to what you currently attempt to do.

And we would be happy to take actual Rcpp questions here.

Cheers, Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list