Hi,
when designing libraries for R, is it possible to call C/Fortran
subroutines from other dynamically loaded code?
The following example crashes R:
********* fn1.c *****************
void twice(int *i)
{
*i = 2 * *i;
}
*********************************
********* fn2.c *****************
extern int twice(int *i);
void negtwice(int *i)
{
*i = -1 * twice(i);
}
*********************************
$ cc -fpic -c fn1.c
$ ld -shared fn1.o -o fn1.so
$ cc -fpic -c fn2.c
$ ld -shared fn2.o -o fn2.so
$ R
R : Copyright 1997, Robert Gentleman and Ross Ihaka
Version 0.61.1 Alpha (December 21, 1997)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.
Type "demo()" for some demos, "help()" for on-line help,
or
"help.start()" for a HTML browser interface to help.
> dyn.load("fn1.so")
> dyn.load("fn2.so")
> .C("negtwice",as.integer(2))
/usr/local/R/bin/R.binary: can't resolve symbol 'twice'
I guess it will not be possible at all but I'm not sure. Has anyone more
experience with dynamic loaded code?
Albrecht
------------------------------------------------------------------
Albrecht Gebhardt email: albrecht.gebhardt at uni-klu.ac.at
Institut fuer Mathematik Tel. : (++43 463) 2700/837
Universitaet Klagenfurt Fax : (++43 463) 2700/834
Villacher Str. 161
A-9020 Klagenfurt, Austria
------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 Thu, 26 Feb 1998, Albrecht Gebhardt wrote:> when designing libraries for R, is it possible to call C/Fortran > subroutines from other dynamically loaded code? >It should be possible, and I thought Ross had actually tested it when we were considering making a libf2c package. However, it definitely doesn't work. Thomas Lumley ------------------------------------------------------+------ Biostatistics : "Never attribute to malice what : Uni of Washington : can be adequately explained by : Box 357232 : incompetence" - Hanlon's Razor : Seattle WA 98195-7232 : : ------------------------------------------------------------ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I have been playing with a large database interface for R, and have
written one complete but useless demonstration and one incomplete but
potentially useful example (with memory mapping of a fixed-format ASCII
file). The idea is to make the file appear like a matrix or data frame but
not have to read it into the R heap.
A description and code can be found at
http://www.biostat.washington.edu/~thomas/Rdb.html
Rdb.nw (noweb literate program)
Rdb.c
Rdb.R
Comments?
Thomas Lumley
------------------------------------------------------+------
Biostatistics : "Never attribute to malice what :
Uni of Washington : can be adequately explained by :
Box 357232 : incompetence" - Hanlon's Razor :
Seattle WA 98195-7232 : :
------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._