Libz not affiliated with Xcode

In my project, I have several binding errors, each of which indicates the absence of a liz. Here is an 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) 

Thus, external libraries (cocos2d and GA) cannot find this library. I have it in the library link binary for my purpose, also has the -lz flag in other Linger flags. Removing any of these errors.

What can cause this problem? How can this be solved?

(I already tried things like restarting Xcode, clearing the received data, etc.)

+5
source share
1 answer

There's something awkward with the current version of Xcode. You need to clear all zlib / libz links from your previous attempts in your project, then open / usr / lib in Finder and manually drag and drop libz.dylib into your project along with your source files. This is what just worked for me five minutes ago.

I do not know what happened. I have a prototype project using zlib that compiles correctly, but when I copied and pasted the zip code and copied the support files into my real project, I could not compile with the same zlib-missing errors. The prototype project continues compilation. No difference in setting between projects! In my real project, I tried to add libz.dylib and its unrelated version (libz.1.dylib), I tried to manually add -lz to the layout linker options, to no avail. Yay Finder! Hope this works for you too.

+2
source

All Articles