Unidata / netcdf-cxx4

Official GitHub repository for netCDF-C++ libraries and utilities.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fatal error: hdf5.h no such file or directory version NetCDF-4 C++ 4.3.1

kandogu opened this issue · comments

To report a non-security related issue, please provide:

On ubuntu system when I tried cmake .. command on the terminal it fails at 94% percentage because of absence hdf5.h and it cannot pass ctest can you help me?

So I notice you opening and closing this. Are you still having the issue?

Yes I have the issue and cannot fixed, as I know hdf5.h exist, but cmake .. command does not find it and causes error.

Ok, can you provide some information on your platform, the version of netCDF-C and HDF5 you have installed, and their locations? Also, how are you invoking cmake? What does the command look like? I will try to sort this out with you. :)

I use Ubuntu 19.10 and installed netCDF-4 C++ 4.3.1. For hdf5 I install libdhdf5-dev and its version is 1.10.4+repack-10, location of hdf5 is /usr/include/hdf5/serial/hdf5.h and netCDF library direction is /usr/lib/x86_64-linux-gnu. I'm trying to invoke cmake command as you told in the guide.

canning dependencies of target test_bzip2
[85%] Building C object plugins/CMakeFiles/test_bzip2.dir/blocksort.c.o
[ 87%] Building C object plugins/CMakeFiles/test_bzip2.dir/huffman.c.o
[ 88%] Building C object plugins/CMakeFiles/test_bzip2.dir/crctable.c.o
[ 89%] Building C object plugins/CMakeFiles/test_bzip2.dir/randtable.c.o
[ 90%] Building C object plugins/CMakeFiles/test_bzip2.dir/compress.c.o
[ 92%] Building C object plugins/CMakeFiles/test_bzip2.dir/decompress.c.o
[ 93%] Building C object plugins/CMakeFiles/test_bzip2.dir/bzlib.c.o
[ 94%] Building C object plugins/CMakeFiles/test_bzip2.dir/H5Zbzip2.c.o
/home/dogukan/c++/netcdf-cxx4-4.3.1/plugins/H5Zbzip2.c:6:10: fatal error: hdf5.h: No such file or directory
6 | #include <hdf5.h>
| ^~~~~~~~
compilation terminated.

after I write "cmake ..", error occurs here.

Edit ---
netCDF version is 4.6.2

What happens if you invoke it as follows:

$ cmake .. -DCMAKE_PREFIX_PATH=/usr

Do you see the same issue?

It builds, however, this time it cannot pass ctest, all tests failed.
Edit---
Sorry, it failed "make" command this time and It gives the same error.

For more detailed information

$ cmake .. -DCMAKE_PREFIX_PATH=/usr
-- Found bash: /usr/bin/bash
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
NetCDF C Configuration Summary

General
NetCDF Version: 4.3.1
Configured On: Çrş Şub 5 00:19:15 +03 2020
Host System: x86_64-Linux-5.3.0-29-generic
Build Directory: /home/dogukan/c++/netcdf-cxx4-4.3.1/build
Install Prefix:

Compiling Options
C Compiler: /usr/bin/cc
CFLAGS: -g -Wall -Wno-unused-variable -Wno-unused-parameter -g
CPPFLAGS: -g -Wall -Wno-unused-variable -Wno-unused-parameter -g -Wall -Wconversion
LDFLAGS: -Wl,--no-undefined
AM_CFLAGS:
AM_CPPFLAGS:
AM_LDFLAGS:
Shared Library: yes
Static Library: no
Extra libraries:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/dogukan/c++/netcdf-cxx4-4.3.1/build

$ make
[ 35%] Built target netcdf-cxx4
[ 37%] Built target cxx4_test_var
[ 40%] Built target cxx4_test_dim
[ 42%] Built target cxx4_test_group
[ 45%] Built target cxx4_test_att
[ 48%] Built target cxx4_test_filter
[ 50%] Built target cxx4_test_classic
[ 53%] Built target cxx4_test_var2
[ 55%] Built target cxx4_test_type
[ 58%] Built target cxx4_test_ncFile_Flags
[ 61%] Built target cxx4_test_open_close
[ 63%] Built target examples_simple_xy_rd
[ 66%] Built target examples_simple_xy_wr
[ 68%] Built target examples_pres_temp_4D_wr
[ 71%] Built target examples_sfc_pres_temp_wr
[ 74%] Built target examples_pres_temp_4D_rd
[ 76%] Built target examples_sfc_pres_temp_rd
[ 79%] Built target pres_temp_4D_plugin_rd
[ 81%] Built target examples_simple_xy_wr_formats
[ 84%] Built target pres_temp_4D_plugin_wr
[ 85%] Building C object plugins/CMakeFiles/test_bzip2.dir/H5Zbzip2.c.o
/home/dogukan/c++/netcdf-cxx4-4.3.1/plugins/H5Zbzip2.c:6:10: fatal error: hdf5.h: No such file or directory
6 | #include <hdf5.h>
| ^~~~~~~~
compilation terminated.

Try this:

$ cmake .. -DCMAKE_CXX_FLAGS="-I /usr/include/hdf5/serial/"

Does that allow compilation to work?

No, it gave the same error again.

fatal error: hdf5.h: No such file or directory
    6 | #include <hdf5.h>
      |          ^~~~~~~~
compilation terminated.
make[2]: *** [plugins/CMakeFiles/test_bzip2.dir/build.make:154: plugins/CMakeFiles/test_bzip2.dir/H5Zbzip2.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1833: plugins/CMakeFiles/test_bzip2.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

What happens if you try building with configure instead of cmake?

I tried it and nothing changed, still giving the same error for $ make command. :(

Can you attach the config.log file generated when you ran configure? Thanks!

Generated config log:
config.log

I had the same issue on Ubuntu 18.04 running with WSL, and resolved it by changing the cmake call to:

cmake .. -DCMAKE_C_FLAGS="-I /usr/include/hdf5/serial/" -DCMAKE_PREFIX_PATH=/usr

I believe this is because the auto-generated make files in plugins/misc.dir use the C_INCLUDES variable rather than the CXX_INCLUDES variable.

export CPATH="/path_to_libs/hdf5/include/"