[R] dyn.load and rw1000

gb@stat.umu.se gb at stat.umu.se
Tue Mar 21 22:06:23 CET 2000


Thank you for the detailed help. I finally got version 2 (see below)
working, but only after adding the -mno-cygwin flag to CFLAGS and
DLLLIBS in rw1000/src/gnuwin32/MakeDll. Note, -mno-cygwin, not
--mno-cygwin, and not the suggestion in 'readme.packages', --no-cygwin.

Once again, thanks for the help!


On Tue, 21 Mar 2000, Guido Masarotto wrote:

> 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
>      http://www.xraylith.wisc.edu/~khan/software/gnu-win32/dllhelpers.html
>      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
>      like
>      .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,
>      guido

 Göran Broström                      tel: +46 90 786-5223
 Department of Statistics            fax: +46 90 786-6614
 Umeå University                                         
 SE-90187 Umeå, Sweden              email: gb at stat.umu.se
 http://www.stat.umu.se/egna/gb    ftp://capa.stat.umu.se

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