5

In my project I have several linking errors, each of them points to libz missing. Here is the example:

 Undefined symbols for architecture arm64:   
 "_inflateReset2", referenced from:
          _png_inflate_claim in libcocos2d iOS.a(pngrutil.o)
      "_inflateEnd", referenced from:
          cocos2d::unzCloseCurrentFile(void*) in libcocos2d iOS.a(unzip.o)
          cocos2d::ZipUtils::inflateMemoryWithHint(unsigned char*, long, unsigned char**, long*, long) in libcocos2d iOS.a(ZipUtils.o)
          _png_destroy_read_struct in libcocos2d iOS.a(pngread.o)
          +[GAICompressionUtil gai_dataByInflatingBytes:length:isRawData:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
          _FT_Stream_OpenGzip in libcocos2d iOS.a(ftgzip.o)
          _ft_gzip_stream_close in libcocos2d iOS.a(ftgzip.o)
          _FT_Gzip_Uncompress in libcocos2d iOS.a(ftgzip.o)
          ...
      "_deflate", referenced from:
     +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
      "_deflateInit2_", referenced from:
          +[GAICompressionUtil gai_dataByCompressingBytes:length:compressionLevel:mode:] in libGoogleAnalyticsServices.a(GAICompressionUtil.o)
      "_inflateReset", referenced from:
          _png_decompress_chunk in libcocos2d iOS.a(pngrutil.o)
          _FT_Stream_OpenGzip in libcocos2d iOS.a(ftgzip.o)
          _ft_gzip_file_io in libcocos2d iOS.a(ftgzip.o)

So looks like external libs (cocos2d & GA) can't find this lib. I have it in Link binary with libraries for my target, also have -lz flag in Other Linger flags. Removing any of those keep this errors.

What can cause this problem? How this might be resolved?

(I've already tried things like restarting XCode, cleaning derived data, etc)

4

1 回答 1

2

当前版本的 XCode 存在一些问题。您需要清除之前在项目中尝试的所有 zlib / libz 引用,然后在 Finder 中打开 /usr/lib 并手动将 libz.dylib 与源文件一起拖到项目中。这就是五分钟前对我有用的方法。

我不知道怎么了。我有一个使用 zlib 可以正确编译的原型项目,但是当我复制并粘贴邮政编码并将支持文件复制到我的真实项目中时,我无法编译,并出现相同的 zlib-missing 错误。原型项目继续编译。项目之间的设置没有区别!在我的真实项目中,我尝试添加 libz.dylib 并且它是非链接版本(libz.1.dylib),我尝试手动将 -lz 添加到链接器构建选项中,但均无济于事。耶发现者!我希望这也对你有用。

于 2015-08-24T00:56:35.857 回答