问题描述
我在我的 iphone 应用程序中包含了 <zlib.h>
以及我正在模拟 Brad Larson 提供的 Molecules 示例代码的源代码,但是,当我构建项目时,它返回如下错误.谁能帮我指出这是图书馆链接问题还是我遗漏了什么?
I have included <zlib.h>
in my iphone application and the source code I was mocking up the sample code of Molecules provided by Brad Larson, however, when I build the project, it returns the error as below. Can anyone point out for me whether this is a library linking problem or am I missing something else?
"_deflate", referenced from: -[NSData(Gzip) gzipDeflate] in NSData+Gzip.o "_inflateEnd",
referenced from: -[NSData(Gzip) initWithGzippedData:] in NSData+Gzip.o "inflateInit2",
referenced from: -[NSData(Gzip) initWithGzippedData:] in NSData+Gzip.o "_inflate",
referenced from: -[NSData(Gzip) initWithGzippedData:] in NSData+Gzip.o "_deflateEnd",
referenced from: -[NSData(Gzip) gzipDeflate] in NSData+Gzip.o "deflateInit2", referenced
from: -[NSData(Gzip) gzipDeflate] in NSData+Gzip.o ld: symbol(s) not found collect2: ld
returned 1 exit status
推荐答案
在 Target 的 Build Settings
选项卡中,向下滚动到 Other Linker Flags
部分并确保 -lz
在该字段中.这将链接到内置的 zlib,您的错误应该会消失.
In your Target's Build Settings
tab, scroll down to the Other Linker Flags
section and make sure -lz
is in the field. This will link against the built-in zlib, and your error should go away.
更改链接器标志后,您必须在再次构建之前从 Product
菜单中选择 Clean
.
After changing the Linker Flags you must select Clean
from the Product
menu before building again.