# Can't find ZLIB (missing: ZLIB\_LIBRARY) Ubuntu 20 CMake

**URL:** https://discourse.cmake.org/t/cant-find-zlib-missing-zlib-library-ubuntu-20-cmake/2610
**Category:** Usage
**Created:** [January 23, 2021, 6:44pm UTC](https://discourse.cmake.org/t/cant-find-zlib-missing-zlib-library-ubuntu-20-cmake/2610 "2021-01-23T18:44:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cubbins](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@cubbins](https://discourse.cmake.org/u/cubbins)
#### Post date: [January 23, 2021, 6:44pm UTC](https://discourse.cmake.org/t/cant-find-zlib-missing-zlib-library-ubuntu-20-cmake/2610/1 "2021-01-23T18:44:48Z")

</div>

I am compiling github’s OpenROAD.  
Following the instructions.

1. github clone
2. cd OpenROAD
3. mkdir build, and cmake …

The cmake checks, proceeds and stops, with an error  
‘Could NOT find ZLIB’

I have issued the command, within Ubuntu version 20:  
export ZLIB\_LIBRARY=/usr/local/zlib/lib  
export ZLIB\_INCLUDE\_DIR=/urs/local/zlib/include

But still receive a not found a error. Someone  
said on the internet, there is a fundamental error within  
CMake, with regard to ZLIB. Could someone suggest a  
solution to this problem? The ZLIB software is  
installed.

from CMake:  
– Could NOT find ZLIB (missing: ZLIB\_LIBRARY ZLIB\_INCLUDE\_DIR)  
– Could NOT find ZLIB (missing: ZLIB\_LIBRARY ZLIB\_INCLUDE\_DIR)

---

<div class="post-metadata">

### Author: ![colt](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/c/c67d28/32.png) [@colt](https://discourse.cmake.org/u/colt)
#### Post date: [January 24, 2021, 1:22am UTC](https://discourse.cmake.org/t/cant-find-zlib-missing-zlib-library-ubuntu-20-cmake/2610/2 "2021-01-24T01:22:05Z")

</div>

This directory: `/usr/local/Zlib ` is not the one of default system to install software. The usual would be to Zlib to install on /usr/local/lib, /usr/local/include, /usr/local/share, etc. During its installation it seems it was executed `./configure --prefix=/usr/local/zlib` that was used to create this dir and then install zlib components on it.

So cmake doesn’t know that it exists. I enterthe build dir and then execute: ` CMAKE_PREFIX_PATH=/usr/local/zlib cmake .` too see if its detected then.

P.S: I used this to detect libraries, but your problem seems related to header files detection, so take it with a grain of salt. If it does not work, you could create symbolic links from zlib/include to `/usr/local/include`

---

<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: [January 25, 2021, 3:33pm UTC](https://discourse.cmake.org/t/cant-find-zlib-missing-zlib-library-ubuntu-20-cmake/2610/3 "2021-01-25T15:33:30Z")

</div>

> [@cubbins](#):
>
> export ZLIB\_LIBRARY=/usr/local/zlib/lib  
> export ZLIB\_INCLUDE\_DIR=/urs/local/zlib/include

These are environment variables. Find modules sometimes, but rarely, use these. You need to pass them as CMake variables. For example:

```console
cmake -DZLIB_LIBRARY=/usr/local/zlib/lib/libz.so -DZLIB_INCLUDE_DIR=/usr/local/zlib/include $builddir

```
