0

我正在尝试对与 iOS 5.0 链接的 Snow Leopard (10.6) 上的 Xcode 4.2 项目进行分析(如 gcov 风格分析)。我已经打开 -fprofile-arcs -ftest-coverage 并且我正在链接 -lprofile_rt。使用 LLVM 3.0 编译。

我的目标是一个由单元测试包测试的静态库。

一切都编译得很好,但是在单元测试包的链接步骤中,我得到:

ld: in Foo/DerivedData/Foo/Build/Intermediates/Foo.build/Debug Profile-iphonesimulator/UnitTests.build/Objects-normal/i386/TestUtilities.o, in section _DATA,_const reloc 0: GENERIC_RELOC_SECTDIFF missing following pair for architecture i386

这是实际的链接步骤:

setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -bundle -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk "-LFoo/Build/Products/Debug Profile-iphonesimulator" -L/Developer/usr/lib "-FFoo/Build/Products/Debug Profile-iphonesimulator" -F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/Library/Frameworks -F/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Developer/Library/Frameworks -filelist "Foo/DerivedData/Foo/Build/Intermediates/Foo.build/Debug Profile-iphonesimulator/UnitTests.build/Objects-normal/i386/UnitTests.LinkFileList" -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fprofile-arcs -ftest-coverage -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -lFoo -framework Foundation -framework SenTestingKit -lprofile_rt -o "Foo/DerivedData/Foo/Build/Products/Debug Profile-iphonesimulator/UnitTests.octest/UnitTests"

任何人有任何想法为什么我不能链接?

4

1 回答 1

0

原来它似乎是编译器中的一个错误。我的 TestUtilities.m 文件非常复杂(有很多 STAssertEquals)。STAssertEquals 宏扩展为带有@try/catch 块的相当复杂的代码块。通过定义我自己的 STAssertEquals 功能稍少但没有@try 块,它简化了我生成的代码,足以让编译器/链接器对此感到满意。我会提交一个合适的雷达。

于 2012-02-05T05:52:14.147 回答