[R] Dynamic loading problem.

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Sep 14 17:23:53 CEST 2001


On Fri, 14 Sep 2001, Rolf Turner wrote:

> I'm having a dynamic loading problem that seems to be
> caused by exponentiation (the ** operator in Fortran/ratfor).
>
> This can be illustrated by the following toy example:
>
> ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===
> % cat foo.r
> subroutine foo(x,n)
> x = x**n
> return
> end
>
> % f77 -c foo.r
> /tmp/ratfor.06661.0.f:
>         foo:
> % R CMD SHLIB -o foo.so foo.o
> gcc -G  -o foo.so foo.o  -L/usr/local/lib
> % R -q
>
> > dyn.load("foo.so")
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
>         unable to load shared library "/home1/faculty/rolf/Traal/Temp/foo.so":
>   ld.so.1: /usr/local/lib/R/bin/R.bin: fatal: relocation error: file /home1/faculty/rolf/Traal/Temp/foo.so: symbol __pow_ri: referenced symbol not found
> > q()
> ===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===
>
> I presume/hope that by handing SHLIB some other flags or by
> specifying some environment variable or other, or by ..., I should
> be able to get dyn.load() to find ``__pow_ri''.
>
> The same problem does NOT arise when I use Splus3.4 SHLIB and
> dyn.load.shared() in Splus3.4, so ``__pow_ri'' must be around
> somewhere.
>
> Can anyone tell me (in simple, prescriptive, explicit terms) what
> I need to do to alleviate this problem?
>
> I'm running R-1.3.1 on a Sun Sparc Ultra-5, under SunOS 5.7/Solaris 2.7.

Use Fortran!  Seriously, on my Ultra1

auk% R CMD SHLIB foo.f
f77   -PIC  -O -c foo.f -o foo.o
foo.f:
        foo:

gcc -G  -o foo.so foo.o  -L/usr/local/lib -R/opt/SUNWspro/lib
-L/opt/SUNWspro/lib -L/opt/SUNWspro/WS6U1/lib -L/usr/ccs/lib -L/usr/lib
-lF77 -lM77 -lsunmath -lm -lcx

shows what's up, and with

dummy.f (empty)

auk% R CMD SHLIB foo.o dummy.f
f77   -PIC  -O -c dummy.f -o dummy.o
dummy.f:
gcc -G  -o foo.so foo.o dummy.o  -L/usr/local/lib -R/opt/SUNWspro/lib
-L/opt/SUNWspro/lib -L/opt/SUNWspro/WS6U1/lib -L/usr/ccs/lib -L/usr/lib
-lF77 -lM77 -lsunmath -lm -lcx

fixes it.

S-PLUS comes (usually) with support for ratfor: R does not.


-- 
Brian D. Ripley,                  ripley at 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-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