We are living as nomad in Mexico !!

Install zlib

You can see the following
  • Want to install zlib

Table of contents


For Ubuntu

* When the version is 22.04

> sudo apt update
> sudo apt install -y zlib1g zlib1g-dev

For Mac OS

Install with brew.

> brew install zlib

For source code

Configure option

--prefix The installation path

For CentOS / Ubuntu / MacOS

* When installing version 1.2.11

> cd /usr/local/src
> sudo wget https://www.zlib.net/zlib-1.2.11.tar.gz
> sudo tar xvfz zlib-1.2.11.tar.gz
> cd zlib-1.2.11
> sudo ./configure --prefix=/usr/local/zlib/1_2_11
> sudo make
> sudo make install

Create Symbolic Link

Create installed libraries to under "/usr/local" by symbolic link.

* When installing version 2.2.7

// /usr/local/include
> sudo ln -s /usr/local/zlib/1_2_11/include/zconf.h /usr/local/include/
> sudo ln -s /usr/local/zlib/1_2_11/include/zlib.h /usr/local/include/

// /usr/local/lib
> sudo ln -s /usr/local/zlib/1_2_11/lib/libz.a /usr/local/lib/
> sudo ln -s /usr/local/zlib/1_2_11/lib/libz.so /usr/local/lib/
> sudo ln -s /usr/local/zlib/1_2_11/lib/libz.so.1 /usr/local/lib/
> sudo ln -s /usr/local/zlib/1_2_11/lib/libz.so.1.2.11 /usr/local/lib/

// /usr/local/lib/pkgconfig
> sudo ln -s /usr/local/zlib/1_2_11/lib/pkgconfig/zlib.pc /usr/local/lib/pkgconfig/

Set Environment Variable

Setting LD_LIBRARY_PATH and PKG_CONFIG_PATH variables is useful when building or executing other sources.

When copying or creating a symbolic link the library installed under /usr/local, it is recommended to set it.

> vim ~/.bash_profile

* For CentOS / Ubuntu

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

If you want to load shared libraries in the system, create a file which is wrote "/usr/local/lib" under /etc/ld.so.conf.d.

> sudo echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
> sudo ldconfig
> sudo ldconfig -v

🌟The author of this article is:🌟

Kakeru profile

Kakeru Sato

Software Developer

Full stack engineer