hhoeflin / hdf5r

Other
81 stars 23 forks source link

Compilation failed: hdf5.h: No such file or directory #112

Open pavlin-policar opened 5 years ago

pavlin-policar commented 5 years ago

I have installed R in a conda environment and have made sure to also install the HDF5 package. I did this because I don't permission to install system-wide packages, and conda has worked well for me in the past. However, I can't seem to install hdf5r.

I've cloned the repository, cd-ed into the directory and run R CMD build ., but I get the following error:

 checking for file ‘./DESCRIPTION’ ... OK
* preparing ‘hdf5r’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* running ‘cleanup’
* installing the package to build vignettes
      -----------------------------------
* installing *source* package ‘hdf5r’ ...
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for grep that handles long lines and -e... /bin/grep
checking for gcc... /home/ppolicar/miniconda3/envs/cell/bin/x86_64-conda_cos6-linux-gnu-cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/ppolicar/miniconda3/envs/cell/bin/x86_64-conda_cos6-linux-gnu-cc accepts -g... yes
checking for /home/ppolicar/miniconda3/envs/cell/bin/x86_64-conda_cos6-linux-gnu-cc option to accept ISO C89... none needed
checking how to run the C preprocessor... /home/ppolicar/miniconda3/envs/cell/bin/x86_64-conda_cos6-linux-gnu-cpp
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for h5cc... /home/ppolicar/miniconda3/envs/cell/bin/h5cc
checking for HDF5 libraries... yes (version 1.10.2)
checking hdf5.h usability... yes
checking hdf5.h presence... yes
checking for hdf5.h... yes
checking for H5Fcreate in -lhdf5... yes
checking for hdf5_hl.h... yes
checking for H5LTpath_valid in -lhdf5_hl... yes
checking for main in -lhdf5_hl... yes
checking for matching HDF5 Fortran wrapper... /home/ppolicar/miniconda3/envs/cell/bin/h5fc
Found hdf5 with version: 1.10.2
checking for ggrep... /bin/grep
checking whether /bin/grep accepts -o... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
cp 1_10_2/*.c 1_10_2/*.h .
x86_64-conda_cos6-linux-gnu-cc -I/home/ppolicar/miniconda3/envs/cell/lib/R/include -DNDEBUG   -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -I/home/ppolicar/nfs/miniconda/envs/cell/include -I/home/ppolicar/nfs/miniconda/envs/cell/include  -D__USE_MINGW_ANSI_STDIO -fpic  -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -I/home/ppolicar/nfs/miniconda/envs/cell/include -fdebug-prefix-map==/usr/local/src/conda/- -fdebug-prefix-map==/usr/local/src/conda-prefix  -c const_export.c -o const_export.o
In file included from const_export.h:22:0,
                 from const_export.c:23:
global.h:23:10: fatal error: hdf5.h: No such file or directory
 #include <hdf5.h>
          ^~~~~~~~
compilation terminated.
make: *** [/home/ppolicar/miniconda3/envs/cell/lib/R/etc/Makeconf:160: const_export.o] Error 1
ERROR: compilation failed for package ‘hdf5r’
* removing ‘/tmp/RtmphybFB5/Rinst53f974d37756/hdf5r’
      -----------------------------------
ERROR: package installation failed

I've made very sure that hdf5.h actually exists in /home/ppolicar/nfs/miniconda/envs/cell/include, and it seems that it is actually found in checking for hdf5.h... yes.

Any help would be appreciated.

yueqiw commented 5 years ago

Hi,

I encountered a similar issue. The solution is to use the system HDF5 rather than the one from conda.

  1. Make sure you have HDF5 installed via sudo apt-get install libhdf5-dev. However, this doesn't mean that it will be used by hdf5r. which h5cc will probably point you to the conda directory.

  2. run locate h5cc in the terminal and you will see a list of h5cc path. In my case, libhdf5-dev correspond to /usr/bin/h5cc

  3. install.packages("hdf5r", configure.args="--with-hdf5=/usr/bin/h5cc")

According to the configure file, you can specify which HDF5 installation to use with hdf5r:

--with-hdf5=yes/no/PATH location of h5cc or h5pcc for HDF5 configuration
boonepeter commented 5 years ago

I encountered this problem as well (installation caught on the h5cc file in my anaconda directory). @yueqiw 's suggestion worked perfectly, thanks! For some reason locate h5cc does not return the /usr/bin/h5cc location, but that file is there and when passed as an argument it works.

cramirezs commented 5 years ago

Hi,

I have the same issue and no suggestion has worked so far. In my case I am trying to install it with the command devtools::install_github(repo = "hhoeflin/hdf5r").

Thank you, Ciro

Details * installing source package ‘hdf5r’ ... package ‘hdf5r’ successfully unpacked and MD5 sums checked checking for a sed that does not truncate output... /usr/bin/sed checking for gawk... gawk checking for grep that handles long lines and -e... /usr/bin/grep checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking Using provided HDF5 C wrapper... /mnt/BioHome/ciro/bin/miniconda3/bin/h5cc checking for HDF5 libraries... yes (version 1.10.4) checking hdf5.h usability... yes checking hdf5.h presence... yes checking for hdf5.h... yes checking for H5Fcreate in -lhdf5... yes checking for hdf5_hl.h... yes checking for H5LTpath_valid in -lhdf5_hl... yes checking for main in -lhdf5_hl... yes checking for matching HDF5 Fortran wrapper... /mnt/BioHome/ciro/bin/miniconda3/bin/h5fc Found hdf5 with version: 1.10.4 checking for ggrep... /usr/bin/grep checking whether /usr/bin/grep accepts -o... yes configure: creating ./config.status config.status: creating src/Makevars libs make: Warning: File `Makevars' has modification time 178 s in the future cp 1_10_3/.c 1_10_3/.h . gcc -I"/share/apps/R/3.5/lib64/R/include" -DNDEBUG -I/usr/local/include -D__USE_MINGW_ANSI_STDIO -fpic -g -O2 -c const_export.c -o const_export.o In file included from const_export.h:22:0, from const_export.c:23: global.h:23:10: fatal error: hdf5.h: No such file or directory

include

      ^~~~~~~~

compilation terminated. make: ** [const_export.o] Error 1 ERROR: compilation failed for package ‘hdf5r’ \ removing ‘/home/ciro/R/x86_64-pc-linux-gnu-library/3.5/hdf5r’

adomingues commented 4 years ago

FYI: I was also running into similar issues, conda env with R3.5.1 and solved it by installing hdf5 via conda conda install -c anaconda hdf5, and then the package in the usual way: install.packages("hdf5r")

akhst7 commented 4 years ago

I have the same issue even after I did

> install.packages("hdf5r", configure.args="--with-hdf5=/usr/local/Cellar/hdf5/1.10.6/bin/h5cc")

my config output:

All my packages loaded Mon Jan 27 15:32:46 2020* installing *source* package ‘hdf5r’ ...
** package ‘hdf5r’ successfully unpacked and MD5 sums checked
** using staged installation
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for grep that handles long lines and -e... /usr/bin/grep
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking Using provided HDF5 C wrapper... /usr/local/Cellar/hdf5/1.10.6/bin/h5cc
checking for HDF5 libraries... yes (version 1.10.6)
checking hdf5.h usability... yes
checking hdf5.h presence... yes
checking for hdf5.h... yes
checking for H5Fcreate in -lhdf5... yes
checking for hdf5_hl.h... yes
checking for H5LTpath_valid in -lhdf5_hl... yes
checking for main in -lhdf5_hl... yes
checking for matching HDF5 Fortran wrapper... no
Found hdf5 with version: 1.10.6
checking for ggrep... /usr/bin/grep
checking whether /usr/bin/grep accepts -o... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
cp 1_10_3/*.c 1_10_3/*.h .
/usr/local/opt/llvm/bin/clang -fopenmp -I"/usr/local/Cellar/r/3.6.2/lib/R/include" -DNDEBUG   -I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include -D__USE_MINGW_ANSI_STDIO -fPIC  -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c const_export.c -o const_export.o
In file included from const_export.c:23:
In file included from ./const_export.h:22:
./global.h:23:10: fatal error: 'hdf5.h' file not found
#include <hdf5.h>
         ^~~~~~~~
1 error generated.
make: *** [const_export.o] Error 1

Also, I manually configure with --with-hdf5=/usr/local/Cellar/hdf5/1.10.6/bin/h5cc and R CMD INSTALL . --no-configure but got in the same error. Is there a way to tell a default search path for hdf5.h, perhaps /usr/include ? Is it unusual to see no hdf5.h search path in src/Makevars

(base) ➜  ~ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G2022
dipterix commented 4 years ago

Append string Sys.getenv("PATH") with :/usr/local/Cellar/hdf5/1.10.6/bin Copy the string to .Renviron file (use usethis::edit_r_environ()), set PATH to be

PATH=[other search paths]:/usr/local/Cellar/hdf5/1.10.6/bin/
akhst7 commented 4 years ago

@dipterix, I tried your solution and modified .Renviron but run into the same issue;

In file included from const_export.c:23:
In file included from ./const_export.h:22:
./global.h:23:10: fatal error: 'hdf5.h' file not found

my .Renviron:

(``` base) ➜ ~ more .Renviron R_LIBS=/Volumes/Documents/ahoji/Documents/R_lib R_MAX_NUM_DLLs=150akhst7akiakhaki GITHUB_PAT=ae59a6bd20cb1f241fa757c68875398795f0b72d R_MAX_VSIZE=150Gb PATH=/usr/local/bin:/usr/local/opt/llvm/bin:/usr/local/miniconda3/bin:/usr/local/miniconda3/condabin:/opt/X11/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/hdf5/1.10.6/bin


The path, `/usr/local/Cellar/hdf5/1.10.6/bin` points to `h5cc `?  The complier has the right path to the Brew installed h5cc.  I think the issue may be the compiler needs the  path to hdf5.h  explicitly ?
dipterix commented 4 years ago

@akhst7 Today I was trying to install on my server and found the same problem.

Please add gcc to your PATH environment. In my case, it looks like this.

/home/yosh/.linuxbrew/bin:/home/yosh/.linuxbrew/Cellar/hdf5/1.10.6/bin:......
LiangShaw commented 1 year ago

As adomingues suggested, conda install -c anaconda hdf5 does work. And before next step, check h5cc in the conda path, eg which h5cc. I ran into the issue that the command did not work until i reopened the terminal.

Tfirulli commented 4 days ago

I am on a mac and getting the error I used homebrew to instal the Hdf5 and have reinstalled still getting the error. Testing hdf5 by compiling example program...

LiangShaw commented 4 days ago

Hello!您的邮件我已收到。