我正在尝试构建zpipe.c。我通过configure安装了zlib 1.2.5;使; make install。 我已将zpipe.c文件移动到实际的zlib-1.2.5目录中,其中包含zlib.h头文件。
这是我在尝试构建时得到的结果:
[sk@lldma zlib-1.2.5]$ gcc zpipe.c
/tmp/ccZ2OBz0.o: In function `def':
zpipe.c:(.text+0x3c): undefined reference to `deflateInit_'
zpipe.c:(.text+0x8f): undefined reference to `deflateEnd'
zpipe.c:(.text+0xe2): undefined reference to `deflate'
zpipe.c:(.text+0x163): undefined reference to `deflateEnd'
zpipe.c:(.text+0x1df): undefined reference to `deflateEnd'
/tmp/ccZ2OBz0.o: In function `inf':
zpipe.c:(.text+0x22d): undefined reference to `inflateInit_'
zpipe.c:(.text+0x280): undefined reference to `inflateEnd'
zpipe.c:(.text+0x2c1): undefined reference to `inflate'
zpipe.c:(.text+0x312): undefined reference to `inflateEnd'
zpipe.c:(.text+0x36e): undefined reference to `inflateEnd'
zpipe.c:(.text+0x398): undefined reference to `inflateEnd'
自述文件没有说明在Linux上构建的具体内容,我看到deflate.h和其他.h文件都位于目录中......
zpipe.c的源代码在这里:http://www.zlib.net/zpipe.c
有什么想法吗? TIA
[sk@lldma zlib-1.2.5]$ ls
adler32.c example64 infback.c Makefile.in watcom
adler32.lo example64.o infback.lo make_vms.com win32
adler32.o example.c infback.o minigzip zconf.h
amiga example.o inffast.c minigzip64 zconf.h.cmakein
ChangeLog examples inffast.h minigzip64.o zconf.h.in
CMakeLists.txt examplesh inffast.lo minigzip.c zlib2ansi
compress.c FAQ inffast.o minigzip.o zlib.3
compress.lo gzclose.c inffixed.h minigzipsh zlib.3.pdf
compress.o gzclose.lo inflate.c msdos zlib.h
configure gzclose.o inflate.h nintendods zlib.map
contrib gzguts.h inflate.lo old zlib.pc
crc32.c gzlib.c inflate.o qnx zlib.pc.in
crc32.h gzlib.lo inftrees.c README zpipe.c
crc32.lo gzlib.o inftrees.h treebuild.xml zutil.c
crc32.o gzread.c inftrees.lo trees.c zutil.h
deflate.c gzread.lo inftrees.o trees.h zutil.lo
deflate.h gzread.o libz.a trees.lo zutil.o
deflate.lo gzwrite.c libz.so trees.o
deflate.o gzwrite.lo libz.so.1 uncompr.c
doc gzwrite.o libz.so.1.2.5 uncompr.lo
example INDEX Makefile uncompr.o
答案 0 :(得分:14)
问题不在标题中,它编译得很好。问题是链接器无法找到库函数。尝试编译:
gcc zpipe.c -lz
这将使用libz.a
或libz.so
进行编译(取决于您是静态编译还是动态编译),如果正确,这些目标文件应包含缺少的函数。