Xcode 4.2 Developer Preview 中的链接器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6294250/
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
Linker Error in Xcode 4.2 Developer Preview
提问by yariksmirnov
d /Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator/Goozzy.app/Goozzy normal i386
cd /Users/yariksmirnov/Desktop/Goozy/branches/new
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator -F/Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator -filelist /Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Intermediates/Goozzy.build/Debug-iphonesimulator/Goozzy.build/Objects-normal/i386/Goozzy.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40300 -framework CoreData -lz.1.2.3 -framework MobileCoreServices -framework SystemConfiguration -framework CFNetwork -framework QuartzCore -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/yariksmirnov/Library/Developer/Xcode/DerivedData/Goozzy-cugjuvvsrzjqwvfiicxtykbqagux/Build/Products/Debug-iphonesimulator/Goozzy.app/Goozzy
*ld: library not found for -lz.1.2.3*
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
How do I fix this error?
我该如何解决这个错误?
It's very strange -- I compile a build for iOS, but get a error about Mac OS deployment target.
这很奇怪——我为 iOS 编译了一个版本,但收到关于 Mac OS 部署目标的错误。
回答by Jim
You should link libz.dylib
not any specific version. The correct version gets used automatically.
您不应链接libz.dylib
任何特定版本。正确的版本会自动使用。
回答by Jano
Update the libz dylib version in your project definition to whatever your XCode 4.2 is providing. If you are compiling the same code for different targets, check the library version on each of them.
将项目定义中的 libz dylib 版本更新为 XCode 4.2 提供的任何内容。如果您为不同的目标编译相同的代码,请检查每个目标的库版本。
Since SDK 3.2 all versions of libz are symbolic links to the last version (libz.1.2.3 in SDK 4.3), so regardless of what libz-version you choose, you get the last one. See /Developer/Platforms/iPhoneOS.platform/DeviceSupport/Latest/Symbols/usr/lib.
由于 SDK 3.2 所有版本的 libz 都是指向最后一个版本(SDK 4.3 中的 libz.1.2.3)的符号链接,因此无论您选择什么 libz 版本,您都会得到最后一个。请参阅 /Developer/Platforms/iPhoneOS.platform/DeviceSupport/Latest/Symbols/usr/lib。
I don't know what Apple will do in the future. If you link to libz you are likely to keep linking to the latest version. A change in the major number of the library (libz-X) could break compatibility, so a safer choice is to keep linking the same version you have now. Your choice.
我不知道苹果未来会做什么。如果您链接到 libz,您可能会继续链接到最新版本。库 (libz-X) 的主要编号的更改可能会破坏兼容性,因此更安全的选择是继续链接您现在拥有的相同版本。你的选择。