CMake Error(could not find HDF5)

Hi all,
I recompiled OpenMC today and met the following error.

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Unable to determine HDF5 C flags from HDF5 wrapper.
-- Unable to determine HDF5 C version from HDF5 wrapper.
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find HDF5 (missing: HDF5_INCLUDE_DIRS) (found version "")
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindHDF5.cmake:929 (find_package_handle_standard_args)
  CMakeLists.txt:62 (find_package)

I’ve tried reinstall libhdf5-dev and cmake. Still not work. Had somebody similar problems?

@kingyue, What is the output of h5cc -showconfig command?
Did you try with

 HDF5_ROOT=/usr cmake ..

to compile?

1 Like

I found that h5cc -showconfig show the config of the h5cc installed in anaconda3. Then I removed the h5cc in anaconda, reinstalled libhdf5-dev again and tried HDF5_ROOT=/usr cmake ... Still the same problem.

h5cc -showconfig now shows the following output:

        SUMMARY OF THE HDF5 CONFIGURATION
        =================================

General Information:
-------------------
               HDF5 Version: 1.10.4
              Configured on: Mon, 13 Apr 2020 12:15:08 +0000
              Configured by: Debian
                Host system: x86_64-pc-linux-gnu
          Uname information: Debian
                   Byte sex: little-endian
         Installation point: /usr
                Flavor name: serial

Compiling Options:
------------------
                 Build Mode: production
          Debugging Symbols: no
                    Asserts: no
                  Profiling: no
         Optimization Level: high

Linking Options:
----------------
                  Libraries: static, shared
  Statically Linked Executables:
                    LDFLAGS: -Wl,-Bsymbolic-functions -Wl,-z,relro
                 H5_LDFLAGS: -Wl,--version-script,$(top_srcdir)/debian/map_serial.ver
                 AM_LDFLAGS:
            Extra libraries: -lpthread -lsz -lz -ldl -lm
                   Archiver: ar
                   AR_FLAGS: cr
                     Ranlib: x86_64-linux-gnu-ranlib

Languages:
----------
                          C: yes
                 C Compiler: /usr/bin/gcc
                   CPPFLAGS: -Wdate-time -D_FORTIFY_SOURCE=2
                H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L   -DNDEBUG -UH5_DEBUG_API
                AM_CPPFLAGS:
                    C Flags: -g -O2 -fdebug-prefix-map=$(top_srcdir)=. -fstack-protector-strong -Wformat -Werror=format-security
                 H5 C Flags:  -std=c99  -pedantic -Wall -Wextra -Wbad-function-cast -Wc++-compat -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings -finline-functions -s -Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn -O
                 AM C Flags:
           Shared C Library: yes
           Static C Library: yes


                    Fortran: yes
           Fortran Compiler: /usr/bin/gfortran
              Fortran Flags: -g -O2 -fdebug-prefix-map=$(top_srcdir)=. -fstack-protector-strong
           H5 Fortran Flags:  -pedantic -Wall -Wextra -Wunderflow -Wimplicit-interface -Wsurprising -Wno-c-binding-type  -s -O2
           AM Fortran Flags:
     Shared Fortran Library: yes
     Static Fortran Library: yes

                        C++: yes
               C++ Compiler: /usr/bin/g++
                  C++ Flags: -g -O2 -fdebug-prefix-map=$(top_srcdir)=. -fstack-protector-strong -Wformat -Werror=format-security
               H5 C++ Flags:   -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wredundant-decls -Winline -Wsign-promo -Woverloaded-virtual -Wold-style-cast -Weffc++ -Wreorder -Wnon-virtual-dtor -Wctor-dtor-privacy -Wabi -finline-functions -s -O
               AM C++ Flags:
         Shared C++ Library: yes
         Static C++ Library: yes

                       Java: yes
              Java Compiler: /usr/bin/java (openjdk 11.0.7-ea 2020-04-14)


Features:
---------
               Parallel HDF5: no
Parallel Filtered Dataset Writes: no
          Large Parallel I/O: no
          High-level library: yes
                Threadsafety: yes
         Default API mapping: v18
  With deprecated public symbols: yes
      I/O filters (external): deflate(zlib),szip(encoder)
                         MPE: no
                  Direct VFD: no
                     dmalloc: no
  Packages w/ extra debug output: none
                 API tracing: no
        Using memory checker: no
 Memory allocation sanity checks: no
         Metadata trace file: no
      Function stack tracing: no
   Strict file format checks: no
Optimization instrumentation: no

Wow, after I delete Cmake cache and launch cmake again. It works!! Thank you very much @Pranto !!! You saved my weekend