Install hdf5r package in R 4.0.2

While installing the R package “hdf5r“ version 1.3.3, I encountered the error:

1
2
3
4
fatal error: hdf5.h: No such file or directory
#include <hdf5.h>
^~~~~~~~
compilation terminated.

My OS is Debian buster/10.6, and the package “libhdf5-dev” has been installed. It looks R cannot find the path of hdf5 header and library files.

It has been resolved by:

1. Export environment variables for header files

1
2
export C_INCLUDE_PATH=/usr/include/hdf5/serial/:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/include/hdf5/serial/:$CPLUS_INCLUDE_PATH
1
2
3
cd /usr/lib/x86_64-linux-gnu/
sudo ln -s libhdf5_hl_cpp.so.100.1.2 libhdf5_hl.so.100
sudo ln -s libhdf5_cpp.so.103.0.0 libhdf5.so.103

3. Install package “hdf5r”

1
install.packages("hdf5r")

Now there would be OK.