0

我正在开发一个 iPhone 应用程序。我对Xcode不熟悉,所以请多多包涵。我有 iOS 4.1 设备 SDK。当我在“Active ...”下拉框中选择“Simulator”时,我的应用程序编译没有错误并在 iPhone 模拟器中运行。

但是,当我在下拉框中选择“设备”时,我收到以下有关重复符号的链接器错误:

Ld build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone normal armv6
cd /Users/isaacsutherland/fydp/PineCone/PineCone
setenv IPHONEOS_DEPLOYMENT_TARGET 4.1
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/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.1.sdk -L/Users/isaacsutherland/fydp/PineCone/PineCone/build/Debug-iphoneos -L/Users/isaacsutherland/fydp/PineCone/PineCone/../3rd/libGHUnitIPhone -F/Users/isaacsutherland/fydp/PineCone/PineCone/build/Debug-iphoneos -filelist /Users/isaacsutherland/fydp/PineCone/PineCone/build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone.LinkFileList -dead_strip -all_load -ObjC -miphoneos-version-min=4.1 -framework Foundation -framework UIKit -framework CoreGraphics /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Core.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Network.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20Style.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UI.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UICommon.a /Users/isaacsutherland/fydp/PineCone/3rd/three20/Build/Products/Debug-iphoneos/libThree20UINavigator.a -framework QuartzCore -framework CFNetwork -framework MobileCoreServices -framework SystemConfiguration -lz.1.2.3 /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a -lGHUnitIPhone4_0 -o /Users/isaacsutherland/fydp/PineCone/PineCone/build/PineCone.build/Debug-iphoneos/PineCone.build/Objects-normal/armv6/PineCone

ld: duplicate symbol _RedirectionLimit in /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a(libASIHTTPRequest.a-armv6-master.o) and /Users/isaacsutherland/fydp/PineCone/ClientDal/build/Debug-iphoneos/libClientDal.a(libASIHTTPRequest.a-armv6-master.o)
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

这个错误很奇怪,因为它抱怨 _RedirectionLimit 被发现两次——在同一个文件中!libClientDal.a(libASIHTTPRequest.a-armv6-master.o)是有问题的图书馆。有人可以帮助我了解发生了什么吗?这个库最初是如何正确编译的?或者链接器可能试图两次包含同一个库?

这个类似问题中提供的解决方法对我不起作用。

如果您需要更多信息,我很乐意提供——正如我所说,我是 Xcode 开发的新手。

4

3 回答 3

5

当您拥有一个编译成静态库并相互引用的项目网络时,您必须考虑两个不同的问题:

  • 一个项目的Direct Dependencies通知 Xcode 哪些项目相互依赖,因此它知道在项目的依赖关系发生变化时重新编译项目。

  • 项目的链接库实际上包含在其目标代码中。

简而言之,您的直接依赖关系网络可以随心所欲地纠缠在一起,但您必须小心地将每个项目的代码仅链接到应用程序可执行文件中一次

基本上,我的问题是我有 3 个项目 A、B 和 C,并且依赖项看起来像 A=>B、A=>C、B=>C。我将 libC.a 链接到 A 和 B,所以链接器抱怨重复代码。

您需要更改的配置内容位于每个项目目标的目标信息页面上。

于 2010-10-19T08:51:40.900 回答
2

当我使用 -all_load 链接器标志时,这发生在我身上,它强制链接器从所有库中加载所有符号。Three20 项目说你应该使用它,否则类别将不会被加载并且你会得到一个运行时异常。我删除了该标志,并仅为每个需要它的库(Three20 库)添加了 -force_load 标志。另请参阅:-all_load 链接器标志有什么作用?

于 2011-01-13T15:25:44.640 回答
0

我有几个应用程序需要嵌入一个使用 ASI 和 TBXML 的小型自定义库。其中一些应用程序有自己的库版本。为了避免重复符号问题,我复制了每个库的目标,删除了导致问题的 .m 文件。希望能帮助到你。

于 2011-11-21T13:18:29.367 回答