编译zlib

一、前言

    在编译之前,先描述一下lzlib、zlib、lzip的

        Lzlib is a data compression library providing in-memory LZMA compressionand decompression functions, including integrity checking of thedecompressed data. The compressed data format used by the library is thelzip format.Lzlib is written in C.
        lzlib压缩库提供了在内存中的 LZMA 压缩和解压算法功能,包括对数据进行完整性检查。压缩格式是 lzip。

        zlib is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib data format is itself portable across platforms. Unlike the LZW compression method used in Unix compress(1) and in the GIF image format, the compression method currently used in zlib essentially never expands the data. (LZW can double or triple the file size in extreme cases.) zlib's memory footprint is also independent of the input data and can be reduced, if necessary, at some cost in compression. A more precise, technical discussion of both points is available on another page.
        zlib是免费、通用、合法的,也就是说它不受任何专利限制---无损数据压缩库适用于几乎任何计算机和操作系统。 zlib的数据结构本身是跨平台的。不像LZW压缩算法只能用于unix压缩和GIF图片格式,只用zlib压缩算法从来不用扩展数据。(在极短情况下,LZW可以两倍或三倍的压缩文件) zlib内存占用多少依赖于输入的数据。

编译zlib-1.2.8    windows下编译: nmake -f win32/Makefile.msc
    详见Makefile.msc

    Linux下编译: ./configure;make

使用在程序中使用zlib
1、使用静态库
    在vs下,需要把zlib.h、zconf.h和从zlib工程中生成的zlib.lib文件放到你的代码目录下,并且设置项目属性:project->settings->link->category选择input,在library modules中的最后面输入一个空格和zlib.lib,在lgnore libraries输入MSVCRT(否则这个默认库和zlib库会有冲突),然后project-> settings-> c/c++->Category中选择Code generation,在Use run-time Library中选择Debug Multithreaded DLL。
    如果library modules中输入zlib.lib了,那么在代码中添加
#include "zlib.h
    即可,否则还要加入下面这句
#pragma comment( lib, "zlib.lib")

2、使用动态库
      同样,把zlib.h、zconf.h和从zlib工程中生成的zlib1.lib和zlib1.dll复制到自己的源程序文件夹中,代码中添加
#include "zlib.h"
#pragma comment( lib, "zlib1.lib")

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值