4

I am running Ubuntu 20.04 on Windows Subsystem for linux. Cmake is version 3.16.3. I am trying to build a project with a zlib dependency, and I get the following error...

 Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindZLIB.cmake:115 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:1224 (find_package)

Package zlib1g is installed.

How can I rectify this?

Scorb
  • 1,350
  • 9
  • 33
  • 60
  • found version "1.2.11" suggests it is finding the installed library, but it wants a different version – steeldriver May 27 '20 at 19:38
  • I got this error and the reason turned out to be wholly unrelated. Some folders were missing their CMakeLists.txt files. – akauppi Jun 09 '21 at 10:27

4 Answers4

1

My workaround for this issue was to include the library in the command line, like this:

cmake -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.so  ..
Nicolay77
  • 140
  • I had the same problem on MSYS2. My workaround was cmake -DZLIB_LIBRARY=/usr/lib/libz.dll.a .. – magjac Aug 02 '21 at 12:52
1

This seems to be a bug in CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/20127.

magjac
  • 134
  • 3
0

There is a similar issue compiling https://github.com/awslabs/aws-lambda-cpp/tree/master/examples/s3 on Ubuntu 22.04 or Amazon Linux 2023. I resolved it by adding in CMakeLists.txt:

find_package(ZLIB REQUIRED "1.0")

Found here: https://github.com/actions/runner-images/issues/7475

FRa
  • 101
0

I was able to correct this by installing:

sudo apt-get install zlib1g-dev
ZeeKay
  • 1