I'm building a C extension for R, this library also uses the HDF5 library.
I compiled a dynamic library (gcc flag: -fPIC -shared -Wl,-soname,libmy.so -o ../lib/libmy.so
in a 'lib' directory:
$ file /path/to/my/lib/libmy.so
/path/to/my/lib/libmy.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped
LD_LIBRARY_PATH is set:
$ echo $LD_LIBRARY_PATH
/path/to/hdf5/lib:/path/to/my/lib
and now when I want to load my library in R from the directory /path/to/my/src
dyn.load("libmy.so")
I get the following error:
Error in dyn.load("libmy.so") :
unable to load shared object '/path/to/my/src/libmy.so':
/path/to/my/src/libmy.so: cannot open shared object file: No such file or directory
Execution halted
If libmy.so is moved to my current working directory (I don't want this)
mv ../lib/libmy.so ./
the library seems to be loaded but R is still missing the symbols from the hdf5 library:
Error in dyn.load("libmy.so") :
unable to load shared object ' /path/to/my/src/libmy.so':
/path/to/my/src/libmy.so: undefined symbol: H5T_C_S1_g
Execution halted
I also tried load("my.so") instead of "libmy.so".
How can I load my dynamic library ?
Thanks.
EDIT: Added an example on github: https://gist.github.com/lindenb/7cd766cbb37de01f6cce
$ echo $LD_LIBRARY_PATH path/to/hdf5/lib:/path/to/my/lib
– Pierre Jul 25 '14 at 14:04