ld:找不到-lz的库

Luc*_*uca 6 objective-c ios xcode4.2

这让我发疯,当我尝试在模拟器上编译时,一切都很好,但在设备上我得到了这个错误:

ld: library not found for -lz
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

请帮我理解问题的根源:

    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
Run Code Online (Sandbox Code Playgroud)

编辑:

我确实导入了libz.1.1.3.dylib框架: 在此输入图像描述

我在Linked框架中获得的唯一libz就是 libz.1.1.3.dylib 在此输入图像描述

Pet*_*esh 6

您确实libz.dylibLinked frameworks and Libraries项目中指定了库而不是直接引用libz.1.1.3- 通常您应该使用库的最通用版本进行编译而不是更具体的库

其次,确保它libz.dylib存在于iOS SDK下 - 如果它缺失,那么它可能是一个错误安装的SDK(重新安装应该修复).

find /Developer/Platforms -name libz.dylib
Run Code Online (Sandbox Code Playgroud)

应该导致libz.dylibunder 的非空输出iPhoneOS5.0.sdk

另请参阅iPhone的答案- Xcode 4.2预览中的链接器错误,这是一个类似的问题.