Roger.Bivand@nhh.no
2000-May-15 14:26 UTC
[Rd] pythag missing in src/appl/ROUTINES (PR#544)
Full_Name: Roger Bivand Version: 1.0.1 OS: Linux RH 6.1 Submission from: (NULL) (158.37.102.52) I am trying to use pythag() from src/appl in a .Call() function. pythag seems to be missing from the ROUTINES list in appl - putting it in solved the problem:> x <- 1 > y <- 1 > sqrt(x^2 + y^2)[1] 1.414214> dyn.load("pythagtry.so")Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library "/home/rsb/tmp/pythagtry.so": /home/rsb/tmp/pythagtry.so: undefined symbol: pythag> is.loaded("pythag")[1] FALSE ----------------------------------------- /* pythagtry.c */ #include <R.h> #include <Rdefines.h> #include <R_ext/Applic.h> SEXP pytry(SEXP x, SEXP y) { SEXP ans; double xa, xb; xa = NUMERIC_POINTER(x)[0]; xb = NUMERIC_POINTER(y)[0]; PROTECT(ans = NEW_NUMERIC(1)); NUMERIC_POINTER(ans)[0] = pythag(xa, xb); UNPROTECT(1); return(ans); } ------------------------------------------------------------- $ R_HOME=/usr/local/lib/R gcc -I/usr/local/lib/R/include -c pythagtry.c $ gcc -shared -o pythagtry.so pythagtry.o ----------------------------------------------------------- added: C_FUNCTION(pythag) to /usr/local/src/R-1.0.1/src/appl/ROUTINES make make install> x <- 1 > y <- 1 > sqrt(x^2 + y^2)[1] 1.414214> is.loaded("pythag")[1] TRUE> dyn.load("pythagtry.so") > .Call("pytry", x, y)[1] 1.414214 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> From: Roger.Bivand@nhh.no > Date: Mon, 15 May 2000 16:26:11 +0200 (MET DST) > To: r-devel@stat.math.ethz.ch > Subject: [Rd] pythag missing in src/appl/ROUTINES (PR#544) > CC: R-bugs@biostat.ku.dk > X-Loop: R-bugs@biostat.ku.dk > > Full_Name: Roger Bivand > Version: 1.0.1 > OS: Linux RH 6.1 > Submission from: (NULL) (158.37.102.52) > > > I am trying to use pythag() from src/appl in a .Call() function. > > pythag seems to be missing from the ROUTINES list in appl - putting > it in solved the problem:But that is not the purpose of that file. As it says, it is for internal .C and .Fortran entry points, and its entries get put in the search table for such entries. And pythag is not a suitable entry point (its arguments are not pointers, it returns a value ...). The real problem seems to be that nothing internal to R calls pythag, and so pythag.o does not get loaded when R.bin is built. Thus I don't know what it is doing in the R source. The solution is to make one of the modules in src/main call it via a dummy routine, or just to link it with your own code. If we want it in, we should merge pythag.c with something else in src/appl. -- Brian D. Ripley, ripley@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-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._