【问题标题】:Linker Error in Xcode 4.2 Developer PreviewXcode 4.2 开发者预览版中的链接器错误
【发布时间】:2011-06-09 14:16:24
【问题描述】:
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 部署目标的错误。

【问题讨论】:

    标签: iphone xcode ios deployment target


    【解决方案1】:

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

    【讨论】:

    • 如果您可以指出相关文档表明链接到非特定于版本的 dylib 将自动使用最新版本,则此答案将大大改善。
    • 使用符号链接来掩盖次要版本号的更改是一种约定,只要有共享库就一直在使用。它无处不在且古老。您不妨问一下将 / 定义为默认路径分隔符的文档在哪里 - 我确信它隐藏在某些 UNIX 标准的深处,但我认为添加到这个答案中并不是特别有启发性。如果您想花时间挖掘它,请随时编辑我的答案。
    • 感谢您的澄清。我问是因为——不是来自 C++ 背景——我认为它可能是 Xcode 特定的。顺便说一句,我已经对答案投了赞成票。
    【解决方案2】:

    将项目定义中的 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) 可能会破坏兼容性,因此更安全的选择是继续链接您现在拥有的相同版本。您的选择。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      • 1970-01-01
      • 1970-01-01
      • 2012-09-17
      • 2011-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多