LD:找不到库-lz
问题描述:
这是推动我疯了,当我尝试编译在模拟器上,一切正常,但在设备上我得到这个错误:LD:找不到库-lz
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框架:
我在链接的框架得到的唯一libz进行的是libz.1.1.3.dylib
答
你做的Linked frameworks and Libraries
项目,而不是直接引用libz.1.1.3
指定库libz.dylib
- 一般来说,你应该使用最通用的第二,确保libz.dylib
存在于iOS SDK下 - 如果它丢失了,那么它可能是一个错误安装的SDK(重新安装应该修复该问题)。
即
find /Developer/Platforms -name libz.dylib
应导致下iPhoneOS5.0.sdk
一个非空输出为libz.dylib
也看到了答案iPhone - Linker Error in Xcode 4.2 Preview,这是一个类似的问题这一点。
答
我得到了同样的错误有一个不同的库:
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
是。我只是改变debug
没有在所有目标下的CocoaPods
我已导入libz.1.1.3.dylib库,请把我的编辑一看,这正与我同模拟器编译,但由于我试图建立一个档案,我明白了。 – Luca 2012-03-21 11:49:36
是的,模拟器使用与设备不同的位置。你最好导入通用的'libz.dylib'而不是特定的'libz.1.1.3'。尝试'find/Developer/Platforms -name libz.1.1.3.dylib'并检查它是否在'iPhoneOS5.0中找到。sdk' *和*'iPhoneSimulator5.0.sdk'。如果找不到,那么我建议用'libz.dylib'替换它。你应该有一个令人信服的理由使用'1.1.3'版本的libz来引用这个特定的版本(通常这些库是向上兼容的) – Petesh 2012-03-21 11:59:14
我在列表中唯一得到的libz框架是'libz.1.1。 3.dylib',请看看我的更新。 – Luca 2012-03-21 13:03:47