开发者

Unable to build zpipe.c (Zlib sample program)

开发者 https://www.devze.com 2023-03-22 15:05 出处:网络
I\'m trying to build zpipe.c. I\'ve installed zlib 1.2.5 via configure; make; make install. I\'ve moved my zpipe.c file into the actual zlib-1.2.5 directory where it includes the zlib.h header file.

I'm trying to build zpipe.c. I've installed zlib 1.2.5 via configure; make; make install. I've moved my zpipe.c file into the actual zlib-1.2.5 directory where it includes the zlib.h header file.

This is what I get when I attempt to build:

[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'

The README doens't say anything specific about building on Linux and I see that deflate.h and the other .h files are all located in the directory...

The source to zpipe.c is here: http://www.zlib.net/zpipe.c

Any ideas? 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开发者_StackOverflow社区      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


The problem is not in the headers, it compiles fine. The problem is that the linker can't find the library functions. Try compiling with this:

gcc zpipe.c -lz

This will compile with libz.a or libz.so (depending on whether you are static or dynamically compiling), and if correct these object files should contain the missing functions.

0

精彩评论

暂无评论...
验证码 换一张
取 消