The zlib library

About zlib

zlib is an open-source data compression library licensed under a custom zlib license. The authors of this library are highly respected in the software community. Many packages I use rely on zlib for compression and decompression.

By the time you read this, it is possible that the latest version has been updated. You may want to use a newer version, but it's possible a newer version might not work the same way. To ensure a positive outcome, don't upgrade unless you have a good reason to, or if the zlib folks recommend you to do so on their website.

Prerequisites

Zlib has no prerequisites.

Downloading zlib

As I write this, the latest version of zlib is 1.2.3. You can download this, or another version, at http://www.zlib.net/. Assuming you want to install version 1.2.3: download zlib-1.2.3.tar.gz; put this into a temporary folder, such as /tmp/zlib, and follow the rest of these instructions to install it.

For example: downloading zlib using wget:
$ mkdir /tmp/zlib
$ cd /tmp/zlib
$ wget http://www.zlib.net/zlib-1.2.3.tar.gz

Installing zlib

Extract zlib
$ cd /tmp/zlib
$ gzip -dc < zlib-1.2.3.tar.gz | tar -xf -
$ cd zlib-1.2.3
Build zlib
$ ./configure -s --prefix=/usr
$ make
Install zlib (must be root user)
# make install

Files

This version of zlib, when installed, produces the following files:

Zlib Library
/usr/lib/libz.a
/usr/lib/libz.so.1.2.3
/usr/lib/libz.so
/usr/lib/libz.so.1
Zlib C Headers
/usr/include/zlib.h
/usr/include/zconf.h
Zlib Manpage
/usr/share/man/man3/zlib.3

Sometimes you will need to install these to a different place, but most libraries expect to be found in either /lib, /usr/lib, or /usr/local/lib. If you'd rather install these files under /usr/local/lib, for instance, you should pass --prefix=/usr/local to the configure script.

Feedback

I personally dislike outdated documentation. If anything here seems wrong, or perhaps did not work for you, please email me (jay@petio.org) and tell me so I can update it. Thanks!