[R] Shared libraries for use with R
Giovanni Petris
GPetris at uark.edu
Fri Jan 18 21:36:48 CET 2002
I am moving my first steps in writing and compiling C code and calling
it from R. (I am also new to shared libraries...) My
problem is that my C code uses a C function contained in
another library (".a", not ".so" - is that the problem?).
This is how I compile the file with the functions I want to call from R:
cd /export/home/gpetris/
R SHLIB tryit.c
cc -I/export/home/share/R/R-1.4.0/lib/R/include "-I/export/home/gpetris/C" -I/usr/local/include -I/export/home/share/include -KPIC -xO5 -dalign -xlic_lib=sunperf -c tryit.c -o tryit.o
cc -G -o tryit.so tryit.o "-L/export/home/gpetris/lib/SUN/32bit -lutil -lrand" -L/usr/local/lib -L/export/home/share/lib
Compilation finished at Fri Jan 18 12:45:20
So far, so good. But when I dyn.load it in R:
> dyn.load("tryit.so")
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library "/export/home/gpetris/tryit.so":
ld.so.1: /export/home/share/R/R-1.4.0/lib/R/bin/R.bin: fatal: relocation error: file /export/home/gpetris/tryit.so: symbol dmatrix: referenced symbol not found
The function dmatrix is contained in the object file nrutil.o in
the library /export/home/gpetris/lib/SUN/32bit/libutil.a
I was hoping that the flags given to R SHLIB could take care of that,
but apparently I was wrong...
What am I missing? Any help will be greatly appreciated.
Thank you in advance,
Giovanni
--
__________________________________________________
[ ]
[ Giovanni Petris GPetris at uark.edu ]
[ Department of Mathematical Sciences ]
[ University of Arkansas - Fayetteville, AR 72701 ]
[ Ph: (501) 575-6324, 575-8630 (fax) ]
[ http://definetti.uark.edu/~gpetris/ ]
[__________________________________________________]
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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