zlib

Reading Time: 2 minutes

Last Updated: 11/1/2024

Homepage: https://zlib.net
zlib 1.3.1 – Lasted Update: January 22, 2024

The primary purpose of this document is to discuss upgrading zlib.

ZLIB is a standard core library for a lot of systems – not just ubuntu. It is designed to be a compression library that is patent free.

In altering your system be careful to preserve your system in case you make an mistake. [i.e. now would be a good time to make a snapshot; and while you are at it check your NTP settings]

Just to be sure – this is for information and learning purposes only There is no warranty expressed or implied. I strongly suggest testing this on a throw away test system first.


This is what I found on a stock system. It is pretty standard for a package to be behind the released versions. [ Bash; zlib; openssh; openssl ] If the system is plain and ONLY has been touched by using DEB/RPM. Then the system probably isn’t running on the latest release from the actual author – but is at at the version that the distributor releases [ Suse, Canonical, Redhat, FreeBSD, etc].

The following then could tell you what has been “administratively” installed. [ Please see the bottom to learn how to check the actual libraries and not just rely on APT/YUM/RPM which could conceivably just be behind the times]

root@nodex:~$ dpkg -l | grep zlib1g
ii  zlib1g:amd64                           1:1.3.dfsg-3.1ubuntu2.1                 amd64        compression library - runtime
ii  zlib1g-dev:amd64                       1:1.3.dfsg-3.1ubuntu2.1                 amd64        compression library - development

It is assumed that I am talking about working from a common directory. For the purposes of this discussion let’s just assume something like /root/src or /root/source

To pull down the code:

wget https://zlib.net/zlib-1.3.1.tar.gz

extract it:

tar -xzf zlib-1.3.1.tar.gz


Next steps:

cd zlib-1.3.1
./configure
make
make install


If you just did a make install you can do the following to verify the files have been placed. The default location for the unaltered config/make/install is.

root@nodex:# ls -al /usr/local/lib/libz*
-rw-r--r-- 1 root root 149236 Nov  1 19:23 /usr/local/lib/libz.a
lrwxrwxrwx 1 root root     13 Nov  1 19:23 /usr/local/lib/libz.so -> libz.so.1.3.1
lrwxrwxrwx 1 root root     13 Nov  1 19:23 /usr/local/lib/libz.so.1 -> libz.so.1.3.1
-rwxr-xr-x 1 root root 125616 Nov  1 19:23 /usr/local/lib/libz.so.1.3

BTW: When you do make install; this will give you an exact idea of what you are going to have to manipulate if you want to build an RPM or DEB file. [ Those details are not given at this time in this post ]

Also if you are wanting to do a reality check. You can do the following.

root@nodex:# ldconfig -p | grep libz
        libzstd.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libzstd.so.1
        libz.so.1 (libc6,x86-64) => /usr/local/lib/libz.so.1
        libz.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libz.so.1
        libz.so (libc6,x86-64) => /usr/local/lib/libz.so
        libz.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libz.so


And indeed, we see that libz.so.1 is linked to /usr/local/lib/libz.so.1 which is where we [the install] put it. So we are square here. Having said that, at the same time, we do note the previous published version is still in place.

 libz.so.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libz.so.1
 libz.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libz.so

To cut the ties with the old configuration you can simply remove them. We note that MAKE INSTALL did not do that for us.

rm -f /lib/x86_64-linux-gnu/libz.so
rm -f /lib/x86_64-linux-gnu/libz.so.1
ldconfig

This entry was posted in Development, Linux, Programming, Support. Bookmark the permalink.