2009-10-27 27 views
24

próbuję skompilować przykład zpipe.c w moim Linux (Ubuntu 8.04) z gcc, ale ja dostaję masę błędów, spójrz:Błąd Deflate i nadmuchiwania Z zlib

[[email protected]:~/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 
[[email protected]:~/Desktop] 

Zapamiętaj że poprawnie zainstalowałem zLib-dev, ale dlaczego dostaję te błędy?

Odpowiedz

45

Należy również połączyć go z biblioteką zlib. Po prostu dodaj -lz do linii poleceń.

+0

Dziękuję bardzo! –

+0

@Gy Czy możesz dodać to za pomocą wiersza poleceń do polecenia make? – ToothlessRebel

+5

FYI ... musisz umieścić końcówkę -lz na końcu: gcc zlib_main.c -lz – Homer6