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)
There's something wonky with the current version of XCode. You need to purge all zlib / libz references from your previous attempts in your project, then open up /usr/lib in Finder and manually drag libz.dylib into your project alongside your source files. That's what just worked for me five minutes ago.
I don't know what's up. I have a prototype project using zlib which compiles properly, yet when I copied & pasted the zip code & copied the support files over to my real project, I was unable to compile, with the same zlib-missing errors. The prototype project keep compiling. No difference in setup between the projects! On my real project, I tried adding libz.dylib and it's non-linked version (libz.1.dylib), I tried manually adding the -lz to the linker build options, both to no avail. Yay Finder! I hope this works for you, too.