# FindZLIB fails starting with CMake 3.17

**URL:** https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046
**Category:** Usage
**Created:** [July 11, 2022, 5:53pm UTC](https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046 "2022-07-11T17:53:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![lhog](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lhog/32/2588_2.png) [@lhog](https://discourse.cmake.org/u/lhog)
#### Post date: [July 11, 2022, 5:53pm UTC](https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046/1 "2022-07-11T17:53:04Z")

</div>

Hi!

I have a project where FindZLIB used to return correct ZLIB\_LIBRARY\_RELEASE on 3.16.x (zlib1.dll), however starting with 3.17.x and further I’m getting:

```auto

CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.7")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.17/Modules/FindZLIB.cmake:115 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  rts/lib/minizip/CMakeLists.txt:22 (find_package)

```

I’m building on Windows and use mingw environment to get executables.

How do I fix it?

P.S. The project is here: [GitHub - beyond-all-reason/spring: A powerful free cross-platform RTS game engine](https://github.com/beyond-all-reason/spring) And the libs are here: [GitHub - beyond-all-reason/mingwlibs64](https://github.com/beyond-all-reason/mingwlibs64) (to be cloned under the root dir of the project)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [July 11, 2022, 10:24pm UTC](https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046/2 "2022-07-11T22:24:18Z")

</div>

Does passing `--debug-find` to CMake shine any light on this?

---

<div class="post-metadata">

### Author: ![lhog](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lhog/32/2588_2.png) [@lhog](https://discourse.cmake.org/u/lhog)
#### Post date: [July 12, 2022, 8:25am UTC](https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046/3 "2022-07-12T08:25:10Z")

</div>

Yes it does reveal some, thanks for the hint.

My zlib dll is at:  
`C:\spring\mingwlibs64\dll\zlib1.dll`

`log2.txt` has the `--debug-find` output:

```auto
$ cat log2.txt | grep "zlib1(" | grep "mingwlibs64/dll"
    C:/spring/mingwlibs64/dll/lib/(lib|)zlib1(\.dll\.a|\.a|\.lib)
    C:/spring/mingwlibs64/dll/(lib|)zlib1(\.dll\.a|\.a|\.lib)

```

As far as I can tell the second line here should match my path.  
Yet it says: `The item was not found.` in the end

Similar issue is observed with a few other libs (dlls) too.

---

<div class="post-metadata">

### Author: ![lhog](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lhog/32/2588_2.png) [@lhog](https://discourse.cmake.org/u/lhog)
#### Post date: [July 12, 2022, 8:43am UTC](https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046/4 "2022-07-12T08:43:57Z")

</div>

Hmm… I was able to rectify the issue by setting:  
`set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ${CMAKE_FIND_LIBRARY_SUFFIXES})` in my `CMakeLists.txt` overriding the standard `set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib")` set in `Windows-GNU.cmake`.

I must say `.dll.a` is a very strange extension for mingw built libs. At the very least “.dll” should be added to the list too.

Does it qualify for a bug? Should I reopen this one: [https://gitlab.kitware.com/cmake/cmake/-/issues/23714](https://gitlab.kitware.com/cmake/cmake/-/issues/23714) ?

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [July 12, 2022, 12:00pm UTC](https://discourse.cmake.org/t/findzlib-fails-starting-with-cmake-3-17/6046/5 "2022-07-12T12:00:54Z")

</div>

On Windows `.dll` is a runtime dependency. For linking you need `.lib` (MinGW uses `.dll.a` (dynamic lib) or `.a` (static lib) for that). Those are correct extensions to look for for linking.
