[R] Dyn.load of sharing object with GSL library

Victoria Landsman msvika at mscc.huji.ac.il
Fri Sep 10 10:34:04 CEST 2004


Dear R-list,
1) thanks to all who tried to help me in solving my problem and especially
to Prof. Ripley for his prompt replies. My problem was not in the library
path but in the Makevars file. The main lesson is: don't use the quotes in
Makevars as I studied from
http://www.r-project.org/nocvs/mail/r-help/2002/0467.html.
The appropriate line in the Makevars file should be
PKG_LIBS=-L/usr/local/lib/ -lgsl  -lgslcblas
(no quotes).

2) I see that our  /usr/local/lib  directory does not contain libgsl.so file
but only libgsl.a and libgsl.la. May it be a sign of some problem or it is
usual?

I am using R-1.9.1 on Sun Solaris.
Much thanks again, Vicky.



----- Original Message -----
From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
To: "Vicky Landsman" <msvika at mscc.huji.ac.il>
Cc: "r-help" <r-help at stat.math.ethz.ch>
Sent: Thursday, September 09, 2004 7:02 PM
Subject: Re: [R] Dyn.load of sharing object with GSL library


> On Thu, 9 Sep 2004, Vicky Landsman wrote:
>
> > Following the recommendation of Prof. Ripley, I have created the
Makevars
> > file with the line:
> >
PKG_LIBS="-L/usr/lib/libm -lm -L/usr/local/lib/libgsl -lgsl -L/usr/local/lib
> > /libgslcblas -lgslcblas"
> > in the working directory.
>
> No, that's not what I recommended. -L/path/to/libgsl would probably be
> -L/usr/local/lib if libgsl is in /usr/local/lib.  And why do you want -lm?
>
> Please consult your unstated OS's documentation for ld.
>
> > Now I have the code file Example3.c which computes the Bessel function
value
> > (the example is taken from the GSL reference book).
> > I am running:
> > R CMD SHLIB Example3.c
>
> Pleae show us exactly what you get here.
>
> > and all looks good.
> > The dyn.load("Example3.so") fails with the following error message:
> >
> > Error in dyn.load(x, as.logical(local), as.logical(now)) :
> >         unable to load shared library
> > "/fs/users1/guest/msvika/PhD/R_04/Example3.so":
> >   ld.so.1: /usr/local/sbin/R-1.9/R-1.9.1/bin/R.bin: fatal: relocation
error:
> > file /fs/users1/guest/msvika/PhD/R_04/Example3.so: symbol
gsl_sf_bessel_J0:
> > referenced symbol not found
>
> Try ldd /fs/users1/guest/msvika/PhD/R_04/Example3.so and get a local
> expert to interpret it for you.
>
> You will need anything you had in -L in PKG_LIBS in your library run path
> as well.  You may need e.g.
>
> export LD_LIBRARY_PATH=:${LD_LIBRARY_PATH}:/usr/local/lib
>
> and please check with a local expert about this.
>
> > What is wrong?
> > Much thanks, Vicky.
> >
> > ----- Original Message -----
> > From: "Vicky Landsman" <msvika at mscc.huji.ac.il>
> > To: "r-help" <r-help at stat.math.ethz.ch>
> > Sent: Thursday, September 09, 2004 6:18 PM
> > Subject: Re: [R] Adding GSL library path to SHLIB
> >
> >
> > > Dear Prof. Ripley,
> > > We read the archive thread
> > > http://maths.newcastle.edu.au/~rking/R/help/02b/0547.html
> > > Thank you for your help, we will try to create the Makevars file.
> > > Vicky.
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
> > > To: "Vicky Landsman" <msvika at mscc.huji.ac.il>
> > > Cc: "r-help" <r-help at stat.math.ethz.ch>; <leonid at cc.huji.ac.il>
> > > Sent: Thursday, September 09, 2004 3:17 PM
> > > Subject: Re: [R] Adding GSL library path to SHLIB
> > >
> > >
> > > > On Thu, 9 Sep 2004, Vicky Landsman wrote:
> > > >
> > > > > Dear R-list people,
> > > >
> > > > > I asked a similar question a few hours before. I will try to be
more
> > > > > specific.  We like to add the GSL library to the file SHLIB in
order
> > to
> > > > > make it possible to run the C code using GSL functions from R.  We
> > read
> > > >
> > > > Read where?  It's incorrect information and only used for Fortran
> > linking.
> > > >
> > > > > that the path to the libgsl.a should be added to the line
> > shlib_libadd='
> > > > > ' in the file SHLIB but it does not work on our system. Dyn.load
fails
> > > > > with error "referenced symbol <symbolname> not found". What is
wrong?
> > > > > We will much appreciate any help on this.
> > > > >
> > > > > We are using R-1.9.1 on Unix.
> > > >
> > > > You should have a file called Makevars in the directory from which
> > > > you are doing the building, defining PKG_LIBS, maybe
> > > >
> > > > PKG_LIBS="-L/path/to/libgsl -lgsl"
> > > >
> > > > in the same way as you would for a package: see `Writing R
Extensions'.
> > > > I don't think that is documented anywere, though.
> > > >
> > > > --
> > > > 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 272866 (PA)
> > > > Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> > > >
> > > >
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> > >
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
> >
> >
>
> --
> 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 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>




More information about the R-help mailing list