zLib中的压缩和解压功能出现错误

35

我正在尝试使用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]

记住我已经正确安装了zLib-dev,但为什么还会出现这些错误?

1个回答

60

你还需要将其与zlib库链接。 只需在命令行的接近末尾处添加“-lz”即可。


8
请注意,在编译时必须将“-lz”放在末尾:gcc zlib_main.c -lz。 - Homer6
1
@György Andrasek 如何在Windows操作系统上完成此操作 - SVD102

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接