Linux下zlib的安装

本文提供了详细的Zlib库安装步骤,包括如何配置静态库和共享库,并介绍了如何更新运行时链接器缓存来确保正确加载Zlib库。还提供了一个非标准安装的选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装zlib
our configuration
  • install to : /usr/local
  • module types : dynamically and staticly loaded modules, *.so and *.a  
zlib标准安装指导:

zlib library files are placed into /usr/local/lib and zlib header files are placed into /usr/local/include, by default.

  • build static libraries
    • .../zlib-1.2.1]# ./configure
    • .../zlib-1.2.1]# make test
    • .../zlib-1.2.1]# make install
  • build shared libraries
    • .../zlib-1.2.1]# make clean
    • .../zlib-1.2.1]# ./configure --shared  
    • .../zlib-1.2.1]# make test
    • .../zlib-1.2.1]# make install
  • .../zlib-1.2.1]# cp zutil.h /usr/local/include
  • .../zlib-1.2.1]# cp zutil.c /usr/local/include
  • /usr/local/lib should now contain...
    libz.a
    libz.so -> libz.so.1.2.1
    libz.so.1 -> libz.so.1.2.1
    libz.so.1.2.1
  • /usr/local/include should now contain...
    zconf.h
    zlib.h
    zutil.h
  • 可选择的zlib非标准安装指导:
    • create the directory that will contain zlib
      • .../zlib-1.2.1]# mkdir /usr/local/zlib
    • follow the given procedure above, except
      • .../zlib-1.2.1]# ./configure --prefix=/usr/local/zlib
更新软连接:update the run-time linker

/etc/ld.so.cache will need to be updated with the new zlib shared lib: libz.so.1.2.1

  • for standard zlib installation...
    • add /usr/local/lib to /etc/ld.so.conf.d/*conf if specifie path is not present
    • /etc]# ldconfig
    • 如果还是不行的话,则在/lib下建立一个libz.so.1.2.1的软链接名字为libz.so
  • if zlib was installed with a prefix...
    • add /usr/local/zlib/lib to /etc/ld.so.conf
    • /etc]# ldconfig
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值