2012-03-21 172 views
6

這是推動我瘋了,當我嘗試編譯在模擬器上,一切正常,但在設備上我得到這個錯誤: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框架: enter image description here

我在鏈接的框架得到的唯一libz進行的是libz.1.1.3.dylib enter image description here

回答

6

你做的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,這是一個類似的問題這一點。

+0

我已導入libz.1.1.3.dylib庫,請把我的編輯一看,這正與我同模擬器編譯,但由於我試圖建立一個檔案,我明白了。 – Luca 2012-03-21 11:49:36

+0

是的,模擬器使用與設備不同的位置。你最好導入通用的'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

+0

我在列表中唯一得到的libz框架是'libz.1.1。 3.dylib',請看看我的更新。 – Luca 2012-03-21 13:03:47

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 onlydebug是。我只是改變debug沒有在所有目標下的CocoaPods