>>>>> Jim Lemon writes:
> I'm in the process of porting a set of routines from S to R (the
> 'asypow' package) and have struck one or two problems that I've
been
> unable to clear up with the documentation I have. I may simply need a
> pointer to the right docs. I managed to get the code to run with
> minimal changes, but in order to get it to load using library(), had to
> run it through:
> R CMD build ...
> and then
> R INSTALL ...
> This allowed the R code to be read - previously I was getting the
> "library contains no R code" error message when loading with
library()
> even though I had set up things as described in "R-exts"..
However, the
> shared library was not loading. I found that the build/INSTALL sequence
> had done two things:
> 1) concatenated all of the R code into one file, which is okay, but
> kind of messy for anyone to edit.
Why would you want to edit that? Think of the installed version as
``object code'', the thing to edit would be the *sources*, i.e. the
files in PKGDIR/R.
> 2) compiled the FORTRAN source, but renamed the library so that it was
> no longer recognized. When I manually used dyn.load() to load the
> library that I had previously compiled, everything seemed to work.
> I've gone through what I think are the relevant parts of
"R-exts" and
> couldn't find a help page for the "build" command to sort out
the
> compiled library problem. Any hints? (Then I can try to write the man
> pages - joy! )
I assume that somewhere in your R/S code you have a call to dyn.load or
library.dynam to load the shlib, and that code uses a name different
from the PKGNAME.$ext (where $ext is platform-specific) obtained by the
compilation? The simplest solution is to put the following into a file
conventionally called zzz.R:
.First.lib <- function(lib, pkg) library.dynam(PKGNAME, pkg, lib)
where PKGNAME is a character string naming your package.
`Writing R extensions' contains in section `Package subdirectories'
If necessary, one of these files (historically `zzz.R') should
use `library.dynam()' _inside_ `.First.lib()' to load compiled
code.
Maybe this should be improved?
Hope this helps,
-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._