[Rcpp-devel] Question on 5.6 Interfacing C++ code
Steve Lianoglou
mailinglist.honeypot at gmail.com
Wed Apr 20 16:03:07 CEST 2011
Hi,
On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
<sean.mcguffee at gmail.com> 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?
Just to make sure we're all on the same page, you want an R package to
compile some source code into a shared library/dll from inside R?
Not sure if there's a "baked in" way for that to happen, but maybe you
can invoke `R CMD WHATEVER` from inside R using the `system` function:
R> ?system
> Would I use the same command and just include it in a file somewhere in the
> package?
> If so, which file?
Hmm ... I'm curious what you're trying to do, exactly?
> Question 2:
> dyn.load(paste("X", .Platform$dynlib.ext, sep = ""))
>
> Where does .Platform$dynlib.ext come from?
> What does it mean?
> What do it’s components .Platform and $dynlib and .ext mean?
.Platform is lust a normal list -- it is defined internally (I guess).
You can access "named" elements of a list with `$`.
.Platform$dynlyb (or .Platform[['dynlib']]) tells you the extension
your particular system uses for shared libraries:
R> .Platform
$OS.type
[1] "unix"
$file.sep
[1] "/"
$dynlib.ext
[1] ".so"
$GUI
[1] "X11"
$endian
[1] "little"
$pkgType
[1] "mac.binary.leopard"
$path.sep
[1] ":"
$r_arch
[1] "x86_64"
See ?.Platform for more help.
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the Rcpp-devel
mailing list