Xcode 4.2 Developer Preview中的链接器错误

16
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

我该如何修复这个错误?

非常奇怪——我编译iOS版本,但却收到了关于Mac OS部署目标的错误。

2个回答

43

你应该链接libz.dylib而不是任何特定的版本。正确的版本会自动使用。


如果您能指出相关文档并说明链接到非特定版本的dylib将自动使用最新版本,那么这个答案将会大大改善。 - memmons
3
使用符号链接来隐藏次版本号更改是一个约定,自共享库存在以来就一直被使用。这是普遍存在的古老习惯。你可以问一下,将/定义为默认路径分隔符的文档在哪里 - 我相信它埋藏在某个UNIX标准的深处,但我认为将其添加到本回答中并不特别有启发性。如果你愿意花时间去挖掘它,请随意编辑我的回答。 - Jim
1
谢谢澄清。我之所以问是因为——我没有C++背景——我认为这可能是Xcode特定的。顺便说一句,我已经点赞了答案。 - memmons

3

请在项目定义中更新libz dylib版本,使其与您的XCode 4.2提供的版本相匹配。如果您正在为不同的目标编译相同的代码,请检查每个目标上的库版本。

自SDK 3.2以来,所有版本的libz都是符号链接到最后一个版本(SDK 4.3中的libz.1.2.3),因此无论您选择哪个libz版本,您都将得到最新的版本。请参见/Developer/Platforms/iPhoneOS.platform/DeviceSupport/Latest/Symbols/usr/lib。

我不知道苹果未来会做什么。如果您链接到libz,则很可能会继续链接到最新版本。库的主要编号(libz-X)的更改可能会破坏兼容性,因此更安全的选择是继续链接您现在拥有的相同版本。由您决定。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接