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

John McKown john.archie.mckown at gmail.com
Sat Jul 26 17:34:20 CEST 2014

OOPS, I forgot to even look at something. Have you looked at the command:


?? The documentation says:
$R CMD SHLIB --help
Usage: R CMD SHLIB [options] files | linker options

Build a shared object for dynamic loading from the specified source or
object files (which are automagically made from their sources) or
linker options.  If not given via '--output', the name for the shared
object is determined from the first source or object file.

  -h, --help            print short help message and exit
  -v, --version         print version info and exit
  -o, --output=LIB      use LIB as (full) name for the built library
  -c, --clean           remove files created during compilation
  --preclean            remove files created during a previous run
  -n, --dry-run         dry run, showing commands that would be used

Windows only:
  -d, --debug           build a debug DLL

Report bugs at bugs at r-project.org .


On Sat, Jul 26, 2014 at 9:37 AM, John McKown
<john.archie.mckown at gmail.com> wrote:
> On Fri, Jul 25, 2014 at 9:07 AM, Pierre Lindenbaum
> <pierre.lindenbaum at univ-nantes.fr> wrote:
>> ( 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
> I am not any kind of expert, so that this as just a vague possibility
> from someone who just wants to try to help. But I am "concerned" about
> the options in the above. In particular, you have
> "-Wl,-soname,libmy.so" Which looks slightly wrong to me, based on the
> man for "ld". I think that, perhaps, this should be:
> ""-Wl,-soname=libmy.so". Notice the = instead of the ,
>> -o ../lib/libmy.so in a 'lib' directory:
> <snip>
>> the library seems to be loaded but R is still missing the symbols from the
>> hdf5 library:
> Have you looked at the /usr/bin/h5cc-<system type> helper script? It
> has some more stuff in it with gcc parameters, such as:
> -Wl,z,relro,-rpath -lz -ldl -lm -lhdf5, -lhdf5_hl
> apparently the -lhdf5_hl is only needed if
> In fact, from my reading, you might want to use "h5cc" instead of
> "gcc" to compile your shared 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
>> Pierre
> Again, I'm no expert. I'm not even a Linux professional. I work on an
> old-style "mainframe" (z/OS from IBM - aka "big iron"). So please
> excuse me if I am leading you down a blind alley.
> --
> There is nothing more pleasant than traveling and meeting new people!
> Genghis Khan
> Maranatha! <><
> John McKown

There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! <><
John McKown

More information about the R-help mailing list