You can see the following
- Want to install zlib
Table of contents
Reference
- zlib Official Site: https://www.zlib.net/
For Ubuntu
* When the version is 22.04
console
> sudo apt update > sudo apt install -y zlib1g zlib1g-dev
For Mac OS
Install with brew.
console
> brew install zlib
For source code
Configure option
--prefix | The installation path |
---|
For CentOS / Ubuntu / MacOS
* When installing version 1.2.11
console
> 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
console
// /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.
console
> vim ~/.bash_profile
* For CentOS / Ubuntu
.bash_profile
... 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.
console
> sudo echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf > sudo ldconfig > sudo ldconfig -v