[R] R and external C library " cannot open shared object file" while LD_LIBRARY_PATH is set

Pierre Lindenbaum pierre.lindenbaum at univ-nantes.fr
Fri Jul 25 16:07:28 CEST 2014

( cross-posted on SO: http://stackoverflow.com/questions/24955829/ )

I'm building a C extension for R, this library also uses the HDF5 library.

I compiled a dynamic library (gcc flags: -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


       $ echo $LD_LIBRARY_PATH

and now when I want to load my library in R from the directory 


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 ?


More information about the R-help mailing list