Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install/use hdf5r due to issues locating libhdf5_hl.so.200 #188

Open
SuhasSrinivasan opened this issue Jun 10, 2022 · 3 comments

Comments

@SuhasSrinivasan
Copy link

System Details

Operating System = CentOS Linux release 7.9.2009 (Core)

R = 4.2.0

The hdf5 version available through RPM is 1.8.12-13.el7, which is incompatible with hdf5r 1.3.5.
Then, the following solution was used to compile hdf5 1.12.2 from source.
#115 (comment)

But additional issues follow.

Issue 1 - Installation

However, after successfully verifying hdf5 installation, hdf5r installation still fails.

> install.packages("hdf5r", configure.args="--with-hdf5=/usr/local/hdf5/bin/h5cc")
...
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘hdf5r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/R/4.2.0/lib/R/library/00LOCK-hdf5r/00new/hdf5r/libs/hdf5r.so':
  libhdf5_hl.so.200: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/R/4.2.0/lib/R/library/hdf5r’

Workaround for Issue 1

1. Verify the location of hdf5

/usr/local/hdf5
/usr/local/hdf5/lib

2. Add LD_LIBRARY_PATH to .Renviron

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/hdf5/lib

Verify in R through Sys.getenv() that this variable is loaded.

  
**3. Install **
> install.packages("hdf5r", configure.args="--with-hdf5=/usr/local/hdf5/bin/h5cc")
...
* DONE (hdf5r)

Issue 2 - Package loading

This occurs post installation even though .Renviron worked previously.

> library("Seurat")
Attaching SeuratObject
Attaching sp
> Read10X_h5()
Error in Read10X_h5() : Please install hdf5r to read HDF5 files
> library("hdf5r")
Error: package or namespace load failed for ‘hdf5r’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/opt/R/4.2.0/lib/R/library/hdf5r/libs/hdf5r.so':
  libhdf5_hl.so.200: cannot open shared object file: No such file or directory

Workaround for Issue 2

> dyn.load("/usr/local/hdf5/lib/libhdf5_hl.so.200")
> library("hdf5r")
> library("Seurat")
Attaching SeuratObject
Attaching sp
> Read10X_h5()
Error in file.exists(filename) :
  argument "filename" is missing, with no default

Things that did not work for both Issues 1 and 2

  1. Adding LD_LIBRARY_PATH to .bashrc and then source .bashrc
  2. Creating /etc/ld.so.conf.d/custom.conf with hdf5 lib path and then ldconfig
@andrew-w-schroeder
Copy link

andrew-w-schroeder commented Aug 5, 2022

Hi @SuhasSrinivasan , did you ever find a working solution to this issue? I'm experiencing the same error on my CentOS system.

@SuhasSrinivasan
Copy link
Author

Hi @andrew-w-schroeder, please see above. I have identified two issues and provided workarounds for both.

@mmokrejs
Copy link

mmokrejs commented Sep 26, 2024

Hi,
I have same issue here but the cause is that Rhdf5lib provides static libs, not dymanic-ones.

The command

x86_64-pc-linux-gnu-gcc -shared -L/usr/lib64/R/lib -Wl,-O1 -Wl,--as-needed -Wl,-rpath=/usr/lib64/R/lib -o hdf5r.so const_export.o datatype_export.o Wrapper_auto_H5A.o Wrapper_auto_H5.o Wrapper_auto_H5D.o Wrapper_auto_H5DS.o Wrapper_auto_H5E.o Wrapper_auto_H5F.o Wrapper_auto_H5G.o Wrapper_auto_H5I.o Wrapper_auto_H5IM.o Wrapper_auto_H5L.o Wrapper_auto_H5LT.o Wrapper_auto_H5O.o Wrapper_auto_H5P.o Wrapper_auto_H5R.o Wrapper_auto_H5S.o Wrapper_auto_H5TB.o Wrapper_auto_H5T.o Wrapper_auto_H5Z.o Wrapper_auto_H5FDcore.o Wrapper_auto_H5FDfamily.o Wrapper_auto_H5FDlog.o Wrapper_auto_H5FDsec2.o Wrapper_auto_H5FDstdio.o convert.o hdf5r_init.o H5Error.o H5ls.o Wrapper_manual_H5T.o -L/storage/vestec1-elixir/projects/biocev/mmokrejs/apps/anaconda3/lib -lhdf5_hl -lhdf5 -L/storage/vestec1-elixir/projects/biocev/mmokrejs/apps/anaconda3/lib -L/storage/vestec1-elixir/projects/biocev/mmokrejs/apps/anaconda3/lib -L/storage/vestec1-elixir/projects/biocev/mmokrejs/apps/anaconda3/lib -lcrypto -lcurl -lpthread -lsz -lz -ldl -lm -L. -lhdf5_hl -lhdf5 -lz -lm -L/usr/lib64/R/lib -lR
installing to /auto/vestec1-elixir/projects/biocev/gentoo/usr/lib64/R/library/00LOCK-hdf5r/00new/hdf5r/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'hdf5r' in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/usr/lib64/R/library/00LOCK-hdf5r/00new/hdf5r/libs/hdf5r.so':
  libhdf5_hl.so.310: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing '/usr/lib64/R/library/hdf5r'
* restoring previous '/usr/lib64/R/library/hdf5r'

seems to work but during import R cannot find static library and fails to load it.

How can I force hdf5r to pick the static library during linking? Why didn't x86_64-pc-linux-gnu-gcc do it in the above command?

$ R CMD INSTALL --configure-args='--enable-static=yes' hdf5r_1.3.11.tar.gz 
* installing to library '/usr/lib64/R/library'
* installing *source* package 'hdf5r' ...
** package 'hdf5r' successfully unpacked and MD5 sums checked
** using staged installation
configure: WARNING: unrecognized options: --enable-static
$ R CMD INSTALL --configure-args='--enable-static' hdf5r_1.3.11.tar.gz 
* installing to library '/usr/lib64/R/library'
* installing *source* package 'hdf5r' ...
** package 'hdf5r' successfully unpacked and MD5 sums checked
** using staged installation
configure: WARNING: unrecognized options: --enable-static

I solved it by disabling conda env and installing hdf5-1.14.3 libs and headers on the system. Then, h5cc was picked by configure and the R package could be linked and loaded properly. See #100 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants