[R] Neophyte question re using dyn.load and accessing c functions

Robert Gentleman rgentlem at hsph.harvard.edu
Sun Apr 25 20:57:32 CEST 1999



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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list