系统基于ubuntu server 14.04.4 amd64,即Ubuntu系统的服务器版本,基本适用于桌面版

安装

第一步 下载并解压zlib压缩包

打开zlib官网,找到下载链接,右键复制地址:
enter image description here

在Linux中使用wget命令下载,执行如下命令开始下载:

wget http://zlib.net/zlib-1.2.8.tar.gz

解压:

tar zxvf zlib-1.2.8.tar.gz

第二步 开始安装

安装过程比较简单,进入zlib的解压目录,依次执行下面几条命令即可:

配置:

./configure

如果之前没有安装gcc(C 编译器),这一步将报如下错误信息::

xueliang@dev:~/download/zlib-1.2.8$ ./configure
Checking for gcc…
Compiler error reporting is too harsh for ./configure (perhaps remove -Werror).
** ./configure aborting.
xueliang@dev:~/download/zlib-1.2.8$

可以参考这篇文章安装gcc(C 编译器),然后继续下面的操作

编译:

make

如果之前没有安装make命令,这一步将报如下错误信息:

xueliang@dev:~/download/zlib-1.2.8$ make
The program ‘make’ is currently not installed. You can install it by typing:
sudo apt-get install make
xueliang@dev:~/download/zlib-1.2.8$

可以参考这篇文章安装make命令,然后继续下面的操作

对编译结果进行测试:

make test

如果编译无误,会得到如下信息:

xueliang@dev:~/download/zlib-1.2.8$ make test
hello world
zlib version 1.2.8 = 0x1280, compile flags = 0xa9
uncompress(): hello, hello!
gzread(): hello, hello!
gzgets() after gzseek: hello!
inflate(): hello, hello!
large_inflate(): OK
after inflateSync(): hello, hello!
inflate with dictionary: hello, hello!
* zlib test OK *
hello world
zlib version 1.2.8 = 0x1280, compile flags = 0xa9
uncompress(): hello, hello!
gzread(): hello, hello!
gzgets() after gzseek: hello!
inflate(): hello, hello!
large_inflate(): OK
after inflateSync(): hello, hello!
inflate with dictionary: hello, hello!
* zlib shared test OK *
hello world
zlib version 1.2.8 = 0x1280, compile flags = 0xa9
uncompress(): hello, hello!
gzread(): hello, hello!
gzgets() after gzseek: hello!
inflate(): hello, hello!
large_inflate(): OK
after inflateSync(): hello, hello!
inflate with dictionary: hello, hello!
* zlib 64-bit test OK *
xueliang@dev:~/download/zlib-1.2.8$

如果通过测试,就可以开始安装了,执行如下命令完成zlib的安装:

sudo make install

卸载

在zlib的解压目录下,一条命令搞定:

sudo make uninstall

完成卸载:

xueliang@dev:~/download/zlib-1.2.8$ sudo make uninstall
cd /usr/local/include && rm -f zlib.h zconf.h
cd /usr/local/lib && rm -f libz.a; \
if test -n “libz.so.1.2.8” -a -f libz.so.1.2.8; then \
rm -f libz.so.1.2.8 libz.so libz.so.1; \
fi
cd /usr/local/share/man/man3 && rm -f zlib.3
cd /usr/local/lib/pkgconfig && rm -f zlib.pc
xueliang@dev:~/download/zlib-1.2.8$

About Me
后端开发工程师
GitHub Repos