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

Vicky Landsman msvika at mscc.huji.ac.il
Thu Sep 9 20:38:22 CEST 2004


Dear Prof. Ripley,
The GSL reference book explains that lm should be added as well (as far as I
understand, and this is what I saw when I run the file in C in a standard
way). No matter, with lm and without, I get the same picture.
Here is what I get after R CMD SHLIB Example3.c

make: Warning: File `Makevars' has modification time 3.4e+03 s in the future
gcc -I/usr/local/sbin/R-1.9/R-1.9.1/include  -I/usr/local/include   -fPIC  -
g -O2 -c Example3.c -o Example3.o
gcc -G -L/usr/local/lib -o Example3.so Example3.o
-L/usr/local/lib/ -lgsl  -L/usr/local/lib/ -lgslcblas"
make: warning:  Clock skew detected.  Your build may be incomplete.

Running ldd line as you stated, I get the following:
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        /usr/platform/SUNW,Sun-Fire-280R/lib/libc_psr.so.1

Sorry for my ignorance in UNIX, where should I run the line
export LD_LIBRARY_PATH=:${LD_LIBRARY_PATH}:/usr/local/lib ?

Vicky.


> 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
>


> > 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