[R] Dyn.load of sharing object with GSL library
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Jun 9 12:32:46 CEST 2013
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
> 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
> 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.
> R-help at r-project.org mailing list
> 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, 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