# Netcdf complains about hdf5/2

**URL:** <https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852>\
**Category:** Uncategorized\
**Created:** [July 20, 2026, 5:38pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852 "2026-07-20T17:38:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eijkhout](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/eijkhout/32/1963_2.png) [@eijkhout](https://forum.hdfgroup.org/u/eijkhout)\
**Post date:** [July 20, 2026, 5:38pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852/1 "2026-07-20T17:38:45Z")

</div>

I’m using essentially the same script for hdf5 version 1.14 and 2.whatever. But netcdf is happy with 1.14 and not with 2:

```auto
-- Found HDF5: hdf5-shared (found version "2.0.0") found components: C HL
-- Found HDF5 version: 2.0.0
-- Using HDF5 include dir: /scratch/00434/eijkhout/installation/installation-hdf5-2.0.0-stampede3-gcc15.1/include
-- Found Threads: TRUE
-- Checking for HDF5 config header
-- Looking for H5public.h
-- Looking for H5public.h - found
-- Using H5public.h to check for feature macros
-- Checking for H5_HAVE_ZLIB_H
-- Performing Test _has_H5_HAVE_ZLIB_H
-- Performing Test _has_H5_HAVE_ZLIB_H - Failed
CMake Error at cmake/dependencies.cmake:161 (message):
  HDF5 was built without zlib. Rebuild HDF5 with zlib.

```

1. I can not find the instructions on how to specify zlib for cmake. I’m using:

ZLib support in HDF5 was enabled but not found

2.1.1 does not report that.

So: how do I specify zlib in the cmake commandline?

---

<div class="post-metadata">

**Author:** ![jhenderson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@jhenderson](https://forum.hdfgroup.org/u/jhenderson)\
**Post date:** [July 20, 2026, 5:56pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852/2 "2026-07-20T17:56:38Z")

</div>

Hi @eijkhout,

For HDF5 2.0.0, the CMake option was renamed from `HDF5_ENABLE_Z_LIB_SUPPORT` to `HDF5_ENABLE_ZLIB_SUPPORT` to be consistent with other options. If you’re using a zlib that is already installed on your system, passing just `-DHDF5_ENABLE_ZLIB_SUPPORT=ON` should be enough to find that zlib. If the zlib is installed to a non-system directory, you may also have to pass the option `-DZLIB_ROOT=${prefix}`, where `${prefix}` is the top-level directory of where zlib is installed to.

---

<div class="post-metadata">

**Author:** ![eijkhout](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/eijkhout/32/1963_2.png) [@eijkhout](https://forum.hdfgroup.org/u/eijkhout)\
**Post date:** [July 20, 2026, 6:38pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852/3 "2026-07-20T18:38:38Z")

</div>

Here are the options I used:

```auto
    -D HDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON
    -D ZLIB_USE_EXTERNAL=ON
    -D ZLIB_ROOT=/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0
    -D ZLIB_INCLUDE_DIR:PATH=/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/include
    -D ZLIB_LIBRARY:PATH=/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/libz.so

result:

   ZLib support in HDF5 was enabled but not found

```

“If the zlib is installed to a non-system directory,” What is a system directory? Note that zlib supports both pkg-config & cmake modules and I have specified the paths to both. I see that you have lines "find\_package( ZLIB " so I was expecting you to use cmake modules. No?

```auto
[staff netcdf:1598] splitpath CMAKE_PREFIX_PATH
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0
/scratch/00434/eijkhout/installation/installation-libaec-1.1.6-stampede3-gcc15.1.0
/scratch/projects/compilers/intel25.1/ccl/2021.15
/scratch/projects/compilers/intel25.1/mkl/2025.1
/home1/apps/cmake/4.1.1
[staff netcdf:1599] find /scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0 -name \*.cmake
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/cmake/zlib/ZLIB-shared-relwithdebinfo.cmake
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/cmake/zlib/ZLIB-shared.cmake
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/cmake/zlib/ZLIB-static-relwithdebinfo.cmake
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/cmake/zlib/ZLIB-static.cmake
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/cmake/zlib/ZLIBConfig.cmake
/scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/cmake/zlib/ZLIBConfigVersion.cmake

```

---

<div class="post-metadata">

**Author:** ![jhenderson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/73ab20/32.png) [@jhenderson](https://forum.hdfgroup.org/u/jhenderson)\
**Post date:** [July 20, 2026, 6:59pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852/4 "2026-07-20T18:59:13Z")

</div>

Yes, HDF5 relies on CMake’s module to locate zlib. In this case, a system directory would be any of the default directories CMake searches for zlib-related CMake files, which would generally be those listed at [find\_package — CMake 4.4.0 Documentation](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure). Since you have `CMAKE_PREFIX_PATH` set to include your zlib installation directory, I’d expect that you shouldn’t need to pass any options other than `-DHDF5_ENABLE_ZLIB_SUPPORT=ON`. `ZLIB_USE_EXTERNAL` should not be specified, as that option is used to have the HDF5 build process also build zlib from source. `ZLIB_INCLUDE_DIR` and `ZLIB_LIBRARY` also usually don’t need to be set and in some cases doing so will cause issues with CMake being able to properly find zlib.

If specifying just `-DHDF5_ENABLE_ZLIB_SUPPORT=ON` is not enough for CMake to locate the zlib installation, it may be useful to pass the [--debug-find](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-debug-find) option to the `cmake` command to help figure out why it isn’t being located.

---

<div class="post-metadata">

**Author:** ![lrknox](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@lrknox](https://forum.hdfgroup.org/u/lrknox)\
**Post date:** [July 20, 2026, 7:13pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852/5 "2026-07-20T19:13:54Z")

</div>

I can’t guarantee this is the only problem, but according to [hdf5/docs/INSTALL\_CMake\_options.md at develop · HDFGroup/hdf5 · GitHub](https://github.com/HDFGroup/hdf5/blob/develop/docs/INSTALL_CMake_options.md) , ZLIB\_USE\_EXTERNAL defaults to OFF, and the description for the option is “If `ON`, specifies that zlib libraries should be retrieved from an external source and should be built while building HDF5.” To me that option is poorly named because it seems that it would be ON for ZLIB not installed as part of the HDF5 build, but instead ON indicates merely that zlib should be built along with HDF5 using externally acquired source which also requires adding options for downloading the source. I suggest removing “-D ZLIB\_USE\_EXTERNAL=ON” or setting it to OFF.

---

<div class="post-metadata">

**Author:** ![eijkhout](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/eijkhout/32/1963_2.png) [@eijkhout](https://forum.hdfgroup.org/u/eijkhout)\
**Post date:** [July 20, 2026, 7:50pm UTC](https://forum.hdfgroup.org/t/netcdf-complains-about-hdf5-2/13852/6 "2026-07-20T19:50:31Z")

</div>

Amazing. Removing the EXTERNAL option did the trick.

Hdf5 reports:

-- Found ZLIB: /scratch/00434/eijkhout/installation/installation-zlib-1.3.2-stampede3-gcc15.1.0/lib64/libz.so (found version “1.3.2”)  
– H5\_ZLIB\_HEADER=zlib.h

so it is using my zlib.

Now netcdf says:

-- Checking for H5\_HAVE\_ZLIB\_H  
– Performing Test \_has\_H5\_HAVE\_ZLIB\_H  
– Performing Test \_has\_H5\_HAVE\_ZLIB\_H - Success  
– Found ZLIB: /usr/lib64/libz.so (found version “1.2.11”)

which is almost correct: it seems to find zlib in h5, but then does not use mine. However, that is probably an issue for netcdf, not for you.
