R-beta: question on dyn.loaded code
Albrecht Gebhardt
agebhard at zidsrv.sci.uni-klu.ac.at
Thu Feb 26 16:35:51 CET 1998
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list