[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 16:37:48 CEST 2014
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
More information about the R-help
mailing list