这让我发疯,当我尝试在模拟器上编译时,一切正常,但在设备上我遇到了这个错误:
ld: library not found for -lz
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang failed with exit code 1
请帮我理解问题的根源:
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框架:
我在Linked框架中获得的唯一libz是libz.1.1.3.dylib
答案 0 :(得分:6)
您确实在libz.dylib
项目中指定了库Linked frameworks and Libraries
,而不是直接引用libz.1.1.3
- 通常您应该使用库的最通用版本进行编译而不是更具体的一个
其次,确保iOS SDK下方存在libz.dylib
- 如果缺少,则可能是错误安装的SDK(重新安装应修复)。
即
find /Developer/Platforms -name libz.dylib
应导致libz.dylib
iPhoneOS5.0.sdk
的非空输出
另请参阅iPhone - Linker Error in Xcode 4.2 Preview的答案,这与此类似。
答案 1 :(得分:2)
我在不同的库中遇到了同样的错误:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
在search paths
- >下解决此问题user header search paths
- > release
我说:
"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include"
请记住,我只有在存档时才会收到此错误,并且我的存档是基于我的发布方案..
<强>更新强>
我在lpods
库(即cocoapods)遇到了同样的问题(在不同的场合/项目中)..我想出来解决这个问题的方法是通过认识到我的development
上的构建工作正常计划,但不是我的debug
计划。基本上development
方案对build active architectures only
有否,而debug
有肯定。我只是在所有 cocoapods下的目标中将debug
更改为否