2009-10-27 9 views
24

で膨らま:エラーデフレートそして、私はgccで私のLinux(Ubuntuの8.04)に<em><a href="http://www.zlib.net/zpipe.c" rel="noreferrer">zpipe.c</a></em>例をコンパイルしようとしているが、私は見て、いくつかのエラーを取得しています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] 

は覚えておいてください私はzLib-devを正しくインストールしましたが、なぜこのエラーが出ますか?

答えて

45

zlibライブラリにもリンクする必要があります。コマンドラインに-lzを追加するだけです。

+0

ありがとうございました! –

+0

@Gyこれをコマンドラインでmakeコマンドに追加できますか? – ToothlessRebel

+5

FYI ...最後に-lzを置く必要があります:gcc zlib_main.c -lz – Homer6

関連する問題

 関連する問題