From bullard at stat.Berkeley.EDU  Wed Mar  3 01:20:57 2010
From: bullard at stat.Berkeley.EDU (bullard at stat.Berkeley.EDU)
Date: Tue, 2 Mar 2010 16:20:57 -0800 (PST)
Subject: [Rd] linking hdf5, requires setting LD_LIBRARY_PATH
Message-ID: <8654.66.201.56.150.1267575657.squirrel@www.stat.berkeley.edu>

I am writing an R package to interface to hdf5 files (yes I know one
exists, the issue will be demonstrated using that package). I tend to like
to build/install things locally so that aspects of the system I am working
on don't cause problems later when attempting to install elsewhere. To
this end, I build and install the hdf5 libraries w/out incident:

tar xzf hdf5-1.8.4.tar.bz2
cd hdf5-1.8.4
./configure --prefix=/home/jbullard/scratch/hdf5_install
make && make install

Now, I make a shared object using the following (I am compiling hdf5.c
directly in src of the hdf5 package):

gcc -I/home/jbullard/projects/me/R-builder/lib64/R/include
-I/home/jbullard/scratch/hdf5_install/include -I/usr/local/include -fpic
-g -O2 -std=gnu99 -c hdf5.c -o hdf5.o
gcc -shared -L/usr/local/lib64 -o hdf5.so hdf5.o
-L/home/jbullard/scratch/hdf5_install/lib -lhdf5 -lz -lm
-L/home/jbullard/projects/me/R-builder/lib64/R/lib -lR

I then start R and get the following error:

Error in dyn.load("hdf5.so") :
  unable to load shared library '/home/jbullard/scratch/hdf5/src/hdf5.so':
  libhdf5.so.6: cannot open shared object file: No such file or directory

The solution is set LD_LIBRARY_PATH to
/home/jbullard/scratch/hdf5_install/lib

Then things work just fine. However, I dislike this option -- Is there any
other way which things can be orchestrated completely at package install
time? I don't want to go editing any files in the R installation; more
like an option to append something to R's LD_LIBRARY_PATH w/in the
Makevars.in of the package being installed (in this case, hdf5)?

Details of platform below. As always, thanks in advance.

jim

R version 2.11.0 Under development (unstable) (2010-02-08 r51110)
x86_64-unknown-linux-gnu

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

HDF5 Version 1.8.4
R hdf5 package: hdf5_1.6.9.tar.gz
Linux mp-1246 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 02:39:34 UTC
2010 x86_64 GNU/Linux



[Rd] linking hdf5, requires setting LD_LIBRARY_PATH
bullard at stat.Berkeley.EDU