Skip to content

Dyn.load of sharing object with GSL library

2 messages · moghadameh mirzai, Brian Ripley

#
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.
?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A problem.pdf
Type: application/pdf
Size: 4392 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130609/cae127dd/attachment.pdf>
#
On 09/06/2013 08:27, moghadameh mirzai wrote:
Well, don't try to use a Makefile as you do not know what you are doing. 
  Use Makevars instead.
That is missing a =
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`