Quantcast

Dyn.load of sharing object with GSL library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Dyn.load of sharing object with GSL library

moghadameh mirzai
Dear R-list,
I want to use shared library of gsl in R(2.15.1) on unix .I have a makefile such as
CC = gcc
CFLAGS = -fPIC -O2
PKG_LIBS -lgsl -lgslcblas -lm -lpthread
 
OBJS_SPB = calc_spb.o k.o dk.o ddk.o
 
 
calc_spb.so : $(OBJS_SPB)
 
      $(CC) -shared -o calc_spb.so $(LIBS) $(OBJS_SPB)
 
clean :
      rm -f ../*.o *.o
 
clean.so:
      rm -f *.so
 
I use R CMD SHLIB calc_spb.c in terminal window of unix and in my directory was built  calc_spb.o and calc_spb.so.
And  I use dyn.load in R the error is
Dyn.load(“calc_spb.so”)
Error in dyn.load(“calc_spb.so”):
Unable to load shared object ‘/home/mir/cal/calc_spb.so’:
/home/mir/cal/calc_spb.so: undefined symbol :gsl_finite
Thanks to all who tried to help me in solving my problem.
 
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

A problem.pdf (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Dyn.load of sharing object with GSL library

Prof Brian Ripley
On 09/06/2013 08:27, moghadameh mirzai wrote:
> Dear R-list,
> I want to use shared library of gsl in R(2.15.1) on unix .I have a makefile such as

Well, don't try to use a Makefile as you do not know what you are doing.
  Use Makevars instead.

> CC = gcc
> CFLAGS = -fPIC -O2
> PKG_LIBS -lgsl -lgslcblas -lm -lpthread

That is missing a =

>
> OBJS_SPB = calc_spb.o k.o dk.o ddk.o
>
>
> calc_spb.so : $(OBJS_SPB)
>
>        $(CC) -shared -o calc_spb.so $(LIBS) $(OBJS_SPB)

You 'defined' PKG_LIBS not LIBS and your terms are in the wrong order.
Whether the latter matters depends on which 'unix' this is.

On most 'unix' systems a Makevars with

PKG_LIBS = -lgsl -lgslcblas -lm

would suffice.  Or even

PKG_LIBS = `gsl-config --libs`

>
> clean :
>        rm -f ../*.o *.o
>
> clean.so:
>        rm -f *.so
>
> I use R CMD SHLIB calc_spb.c in terminal window of unix and in my directory was built  calc_spb.o and calc_spb.so.
> And  I use dyn.load in R the error is
> Dyn.load(“calc_spb.so”)
> Error in dyn.load(“calc_spb.so”):
> Unable to load shared object ‘/home/mir/cal/calc_spb.so’:
> /home/mir/cal/calc_spb.so: undefined symbol :gsl_finite
> Thanks to all who tried to help me in solving my problem.
>
>
>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


--
Brian D. Ripley,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...