# \[Windows+CMake+custom ZLIB\] Cannot build HDF5 with ZLIB support

**URL:** <https://forum.hdfgroup.org/t/windows-cmake-custom-zlib-cannot-build-hdf5-with-zlib-support/12078>\
**Category:** HDF5 Library\
**Created:** [March 12, 2024, 10:06am UTC](https://forum.hdfgroup.org/t/windows-cmake-custom-zlib-cannot-build-hdf5-with-zlib-support/12078 "2024-03-12T10:06:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pierre](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@pierre](https://forum.hdfgroup.org/u/pierre)\
**Post date:** [March 12, 2024, 10:06am UTC](https://forum.hdfgroup.org/t/windows-cmake-custom-zlib-cannot-build-hdf5-with-zlib-support/12078/1 "2024-03-12T10:06:39Z")

</div>

There are a few similar topics, but I could not find help in them, so here is mine.

I am able to build HDF5 with the following toolchain  
CMake-GUI + Visual Studio 2019/2022  
I am familair with those tools, and I don’t have any problem to build HDF5 without Zlib support.

Now, I want to enable Zlib.  
So I set HDF5\_ENABLE\_Z\_LIB\_SUPPORT to true  
I have correctly filled ZLIB\_DIR, ZLIB\_INCLUDE\_DIR, ZLIB\_LIBRARY\_DEBUG, ZLIB\_LIBRARY\_RELEASE, ZLIB\_USE\_EXTERNAL

But when trying to Configure, Cmake issues a warning  
" ZLib support in HDF5 was enabled but not found"  
and HDF5\_ENABLE\_Z\_LIB\_SUPPORT is reset to FALSE

Indeed, HDF5pubconf.h does not show any ZLIB support (H5\_HAVE\_ZLIB\_H is disabled)

(see screen capture)

What could go wrong ?

 ![hdf5-zlib](https://dbkt.hdfgroup.org/original/2X/d/d7318f7f54b6422e2541bce70c09c1ac678118d0.png)

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [March 12, 2024, 12:30pm UTC](https://forum.hdfgroup.org/t/windows-cmake-custom-zlib-cannot-build-hdf5-with-zlib-support/12078/2 "2024-03-12T12:30:04Z")

</div>

Do **not** set ZLIB\_USE\_EXTERNAL = ON

Setting that ON indicates that you want to build ZLIB from source.

---

<div class="post-metadata">

**Author:** ![pierre](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@pierre](https://forum.hdfgroup.org/u/pierre)\
**Post date:** [March 12, 2024, 12:48pm UTC](https://forum.hdfgroup.org/t/windows-cmake-custom-zlib-cannot-build-hdf5-with-zlib-support/12078/3 "2024-03-12T12:48:38Z")

</div>

You are right, ZLIB\_USE\_EXTERNAL=OFF makes it work.

I was misleaded by the fact that usually, \*\_USE\_INTERNAL states a built-in project dependency and \*\_USE\_EXTERNAL will provide a custom build.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [March 22, 2024, 1:22pm UTC](https://forum.hdfgroup.org/t/windows-cmake-custom-zlib-cannot-build-hdf5-with-zlib-support/12078/4 "2024-03-22T13:22:04Z")

</div>

It has been noted that the naming is not ideal.
