Ld: library not found for -lz

It drives me crazy when I try to compile a simulator, everything is fine, but on the device I got this error:

ld: library not found for -lz Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1 

Please help me understand the source of the problem:

  Ld /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois normal armv7 cd /Users/ZConsulting/Desktop/Fontenay-sous-Bois setenv IPHONEOS_DEPLOYMENT_TARGET 5.0 setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products /Debug-iphoneos -F/Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos -F/Developer/Platforms/iPhoneOS.platform/Developer/SDKs /iPhoneOS5.0.sdk/Developer/Library/Frameworks -filelist /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Intermediates/Fontenay-sous-Bois.build/Debug-iphoneos/Fontenay-sous-Bois.build/Objects-normal/armv7/Fontenay-sous-Bois.LinkFileList -dead_strip -fobjc-arc -miphoneos-version-min=5.0 -framework SenTestingKit -lz -lz.1.1.3 -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework CoreLocation -framework MapKit -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ZConsulting/Library/Developer/Xcode/DerivedData/Fontenay-sous-Bois-dhlecgdgtoldsadoctkyueriyius/Build/Products/Debug-iphoneos/Fontenay-sous-Bois.app/Fontenay-sous-Bois 

EDIT:

I imported the libz.1.1.3.dylib framework: enter image description here

The only libz I got in related structures is libz.1.1.3.dylib enter image description here

+6
source share
2 answers

You specified the libz.dylib library in the Linked frameworks and Libraries element instead of directly linking to libz.1.1.3 - in general, you should use the most general version of the library for compilation, and not the more specific one.

Secondly, make sure libz.dylib present in the iOS SDK - if it is missing, then it may be an incorrectly installed SDK (reinstallation should fix this).

i.e.

 find /Developer/Platforms -name libz.dylib 

should result in a libz.dylib exit for libz.dylib in the iPhoneOS5.0.sdk section

Also see the answer on the iPhone - Linker Error in Xcode 4.2 Preview , which is a similar issue for this.

+6
source

I got the same error with a different library:

 ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) 

to solve this problem, under search paths user header search paths release I put:

 "$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include" 

Keep in mind that I only get this error when archiving, and my archive is based on my release scheme.


update: I have the same problem (in another case / project) for the lpods library (i.e. Cocoapods) .. the way I decided to solve this, I realized that the assembly worked fine according to my development scheme, but not my debug . in principle, the development scheme was not for build active architectures only , while debug had the value yes. I just changed debug to no in all targets under cocoapods

+2
source

Source: https://habr.com/ru/post/911291/


All Articles