使用zLib进行错误缩放和膨胀

Nat*_*pos 28 c compression zlib

我正在尝试使用gcc在我的Linux(Ubuntu 8.04)中编译zpipe.c示例,但是我遇到了一些错误,请看一下:

[ubuntu@eeepc:~/Desktop] gcc zpipe.c
/tmp/ccczEQxz.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xd3): undefined reference to `deflateEnd'
zpipe.c:(.text+0x150): undefined reference to `deflate'
zpipe.c:(.text+0x1e8): undefined reference to `deflateEnd'
zpipe.c:(.text+0x27b): undefined reference to `deflateEnd'
/tmp/ccczEQxz.o: In function `inf':
zpipe.c:(.text+0x314): undefined reference to `inflateInit_'
zpipe.c:(.text+0x382): undefined reference to `inflateEnd'
zpipe.c:(.text+0x3d7): undefined reference to `inflate'
zpipe.c:(.text+0x44b): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4c1): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4f6): undefined reference to `inflateEnd'
collect2: ld returned 1 exit status
[ubuntu@eeepc:~/Desktop]
Run Code Online (Sandbox Code Playgroud)

请记住,我已正确安装zLib-dev,但为什么我会收到此错误?

Gyö*_*sek 50

您还需要将它与zlib库链接.只需将-lz添加到命令行的近端即可.

  • 仅供参考...你必须将-lz放在最后:gcc zlib_main.c -lz (5认同)