ios ld: 找不到 -lz 的库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9803702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:26:50  来源:igfitidea点击:

ld: library not found for -lz

objective-ciosxcode4.2

提问by Luca

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

EDIT:

编辑:

I did import the libz.1.1.3.dylib framework: enter image description here

我确实导入了 libz.1.1.3.dylib 框架: enter image description here

The only libz that i got in the Linked frameworks is the libz.1.1.3.dylibenter image description here

我在链接框架中获得的唯一 libz 是 libz.1.1.3.dylibenter image description here

回答by Petesh

You did specify the library libz.dylibin the Linked frameworks and Librariesitem 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.dylibLinked frameworks and Libraries项目中指定了库,而不是直接引用libz.1.1.3- 通常,您应该使用库的最通用版本进行编译,而不是使用更具体的库

Secondly, make sure that the libz.dylibis present under the iOS SDK - if it's missing, then it may be a mis-installed SDK (reinstall should fix that).

其次,确保libz.dylib存在于 iOS SDK 下 - 如果它丢失,那么它可能是错误安装的 SDK(重新安装应该可以解决这个问题)。

i.e.

IE

find /Developer/Platforms -name libz.dylib

should result in a non-empty output for a libz.dylibunder iPhoneOS5.0.sdk

应导致非空输出的libz.dylibiPhoneOS5.0.sdk

Also see the answer to iPhone - Linker Error in Xcode 4.2 Preview, which is a similar issue to this.

另请参阅iPhone - Linker Error in Xcode 4.2 Preview的答案,这是一个与此类似的问题。

回答by abbood

i got the same error with a different library:

我在不同的库中遇到了同样的错误:

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)

to resolve this, under search paths-> user header search paths-> releasei put:

要解决此问题,请在search paths-> user header search paths->下输入release

"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts/include"

keep in mind that I get this bug only when I archive, and my archive is a based off my release scheme..

请记住,我只有在存档时才会遇到此错误,并且我的存档基于我的发布方案..



update:I got the same problem (on a different occasion/project) for the lpodsLibrary (ie cocoapods).. the way i figured out to solve this is by realizing that the build worked fine on my developmentscheme but not my debugscheme. basically the developmentscheme had nofor build active architectures onlywhereas debughad yes. I simply changed debugto no in allthe targets under cocoapods

更新:我遇到了同样的问题(在不同的场合/项目)lpods图书馆(即 cocoapods)。我想解决这个问题的方法是意识到构建在我的development方案上运行良好,但不是我的debug方案。基本上该development计划没有build active architectures onlydebug有。我干脆把cocoapods下的所有target改成debugno