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
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.
After changing the Linker Flags you must select Clean
from the Product
menu before building again.
Add libz to your project. To do this, follow these steps in Xcode:
You can use this same method to add any library from the list. If the library does not appear on the list, then you know that it is not part of the standard iPhone SDK and you may need to rethink your solution or build the library statically yourself and link your target to that (if even possible).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With