I'm have what's probably a trivial &| silly problem trying to access a
c-function in a shared
library ( R 0.64, under redhat linux 5.2).
R COMPILE rctest.c
R SHLIB -o libRC.so rctest.o
produce a reasonable looking shared library ('nm libRC.so' shows that
the function 'rctest' is present).
In R, the command
dyn.load("/fullpathname/libRC.so")
returns without an error. However, I'm unable to access the function.
E.g.
is.loaded(symbol.C("rctest"))
yields FALSE.
.C("rctest",x)
yields "Error in .C("rctest", x) : C/Fortran function not in load table"
There must be something I'm leaving out, but after searching the
documentation and
help archive, I'm stuck. Does the .so have to be in an R package (if
so, where)?
Thanks,
-------------------
Barnet Wagman
wagman at enteract.com
773-645-8369
1361 N. Hoyne
Chicago, IL 60622
--------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/19990425/efb04208/attachment.html
Neophyte question re using dyn.load and accessing c functions
3 messages · Barnet Wagman, Robert Gentleman, Brian Ripley
On Sun, 25 Apr 1999, Barnet Wagman wrote:
I'm have what's probably a trivial &| silly problem trying to access a
c-function in a shared
library ( R 0.64, under redhat linux 5.2).
R COMPILE rctest.c
R SHLIB -o libRC.so rctest.o
produce a reasonable looking shared library ('nm libRC.so' shows that
the function 'rctest' is present).
In R, the command
dyn.load("/fullpathname/libRC.so")
returns without an error. However, I'm unable to access the function.
E.g.
is.loaded(symbol.C("rctest"))
yields FALSE.
.C("rctest",x)
yields "Error in .C("rctest", x) : C/Fortran function not in load table"
Well when this happens to me it's usually because R configured incorrectly and decided to either prepend (or not) an underscore when it wasn't (or was) needed. Stepping through the code using a symbolic debugger will let you know what's going on (or you could try recompiling with HAVE_NO_SYMBOL_UNDERSCORE, set to the correct value for your machine). robert -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sun, 25 Apr 1999, Robert Gentleman wrote:
On Sun, 25 Apr 1999, Barnet Wagman wrote:
I'm have what's probably a trivial &| silly problem trying to access a
c-function in a shared
library ( R 0.64, under redhat linux 5.2).
R COMPILE rctest.c
R SHLIB -o libRC.so rctest.o
produce a reasonable looking shared library ('nm libRC.so' shows that
the function 'rctest' is present).
In R, the command
dyn.load("/fullpathname/libRC.so")
returns without an error. However, I'm unable to access the function.
Just to point out that tests almost nothing (at present). You can have a library that loads with unresolvable symbols that will throw you out of R when you try to use the symbol. About the only think it tests is the presence of the library file.
E.g.
is.loaded(symbol.C("rctest"))
yields FALSE.
.C("rctest",x)
yields "Error in .C("rctest", x) : C/Fortran function not in load table"
Well when this happens to me it's usually because R configured incorrectly and decided to either prepend (or not) an underscore when it wasn't (or was) needed. Stepping through the code using a symbolic debugger will let you know what's going on (or you could try recompiling with HAVE_NO_SYMBOL_UNDERSCORE, set to the correct value for your machine).
You can test if the configuration is right by library(mva) example(cmdscale) If that fails it is the system configuration: if it works it is your example, about which we will need to know more to help.... (This is such a common system for R it is hard to imagine that configure did not work, but there is always a first time.)
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._