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.
That should probably look like this instead: PKG_LIBS="-L/usr/local/lib -lgsl -lgslcblas -lm" The math library (-lm) should not be necessary here but I left it in case it's needed by your [unspecified] OS for some reason.
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.
Shared library linkage often allows symbols to remain undefined until runtime by design. As such, there would be no error message.
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
You may need the following environment variable set prior to running R. It would be best added to your .profile. $ export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:/usr/dt/lib:/usr/lib And why in the world is your R installation located in a directory for system binaries? Perhaps it would be better located as '/usr/local/R-1.9.1' or '/opt/R-1.9.1' instead. ---------------------------------------------------------- SIGSIG -- signature too long (core dumped)