Barnet Wagman
1999-Apr-25 18:41 UTC
[R] Neophyte question re using dyn.load and accessing c functions
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
Robert Gentleman
1999-Apr-25 18:57 UTC
[R] Neophyte question re using dyn.load and accessing c functions
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._