[R] dyn.load and rw1000

Guido Masarotto guido at sirio.stat.unipd.it
Tue Mar 21 12:54:42 CET 2000

On Tue, Mar 21, 2000 at 10:34:07AM +0100, gb at stat.umu.se wrote:
> How do I compile a Fortran subroutine or a C function so that it can be
> dyn.loaded in the windows version of R-1.0.0? I use Cygnus C and Fortran 
> compilers (and mingw-something). 

  There are at least two way (the second is the one we use to build
  the contrib section of CRAN):

  1) R for Windows can dyn.load standard Windows dll. You can find
     details on how to build them with the tools you are using at
     When, you have got the dll, just 'dyn.load("full/path/to/the/dll")'
     will make the exported symbols from the dll available for
     .C and .Fortran. In general, it is better to use
     the 'mingw' version of the tools (i.e., remember to pass
     the --mno-cygwin flags to the compiler and the linker).

  2) Organize the R, Fortran and C source as an R package. Details are
     in the R Extension Writer Manual. It is quite easy. Essentially just
     put all under a directory with the structure
     my.package ------|
                      |____R <- here the R sources must go
                      |____src <- here put the C and Fortran source

     Then, put 'my.package'  under rw1000/src/library and install
     (if you haven't done before) the 'rw1000sp.zip' part of the
     binary distribution. Then, from rw1000/src/gnuwin32
     > make pkg-my.package
     should do all the work, not only the building of the dll but also
     the istallation of the R interface (and of the help, if you have a
     my.package/man sub dir with the Rd files, 
     (but before trying 'make ...'  read the README.packages
     available in the 'rw1000sp.zip' archive (after installation
     you will find it in the main rw1000 directory)).
     In this case, rebember to add to your R sources something
     .First.lib <- function (lib, pkg) 
       library.dynam("my.package", pkg, lib)
       #other initialization stuff here
     If all will go well, do a 'library(my.package)' and ....

     Hoping this help,

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list