ld:找不到-lz的库 [英] ld: library not found for -lz
问题描述
这让我发疯,当我尝试在模拟器上编译时,一切正常,但在设备上我收到了这个错误:
This is driving me crazy, when i try to compile on the simulator, everything is ok, 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
编辑:
我确实导入了libz.1.1.3.dylib框架:
I did import the libz.1.1.3.dylib framework:
我在Linked框架中获得的唯一libz是 libz.1.1.3.dylib
The only libz that i got in the Linked frameworks is the libz.1.1.3.dylib
推荐答案
您确实指定了库 libz.dylib
在链接框架和库
项目而不是直接引用 libz.1.1.3
- 一般情况下你应该使用用于编译的库的最通用版本而不是更具体的版本
You did specify the library libz.dylib
in the Linked frameworks and Libraries
item rather than the direct reference to libz.1.1.3
- in general you should use the most generic version of a library for compilation rather than a more specific one
其次,请确保 libz.dylib
存在于iOS SDK下 - 如果缺少,则可能是错误安装的SDK(重新安装)应该修复)。
Secondly, make sure that the libz.dylib
is present under the iOS SDK - if it's missing, then it may be a mis-installed SDK (reinstall should fix that).
ie
find /Developer/Platforms -name libz.dylib
应导致的非空输出libz.dylib
iPhoneOS5.0.sdk
另请参阅< a href =https://stackoverflow.com/questions/6932991/libz-dylib-versus-libz-1-2-3-dylib-versus-libz-1-2-5-dylib> iPhone - 链接器错误Xcode 4.2预览,这与此类似。
Also see the answer to iPhone - Linker Error in Xcode 4.2 Preview, which is a similar issue to this.
这篇关于ld:找不到-lz的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!