How to fix fatal error: zlib.h: no such file or directory?

Solution 1:

You should install the development support files for zlib, try:

sudo apt-get install libz-dev

Other package names: zlib1g-dev.

If you've already zlib library, make sure you're compiling your code sources with -lz. See: missing zlib.h in ubuntu.

Solution 2:

Install zlib from it's source, solve my similar error. Download last version from this then:

configure
make -j4
make install