链接器错误(只有模拟器)与自己的库后更新到iPhone SDK 4.0 [英] Linker error (only simulator) with own library after update to iPhone SDK 4.0

查看:193
本文介绍了链接器错误(只有模拟器)与自己的库后更新到iPhone SDK 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新到iPhone SDK 4.0,无法再为iPhone模拟器建立专案。问题是,我不能再找到我自己的库之一的类:

I recently updated to iPhone SDK 4.0 and are no longer able to build my project for the iPhone simulator. The problem is that classes of one of my own libraries can no longer be found by ld:

"_OBJC_CLASS_$_Book", referenced from:
   objc-class-ref-to-Book in Category.o
   (maybe you meant: ...)
ld: symbol(s) not found
collect2: ld returned 1 exit status

我已经阅读过一些类似问题的其他帖子,例如此处。 不幸的是,我的问题与SDK框架无关,但是与我自己的lib,所以提到的解决方案不适用这里。

I already read some other posts about similar problems, like e.g. here. "Unfortunately", my problem has nothing to do with a SDK framework, but with my own lib, so the solutions mentioned there are not applicable here.

在我的目标的Link Binary With Libraries下,库搜索路径是正确的(使用XCode和直接在我的项目文件中的纯文本编辑器检查),并正确添加到gcc命令。

The library is included under "Link Binary With Libraries" of my target, library search paths are correct (checked this with XCode and with a plain text editor directly in my project file) and correctly added to the gcc command.

我使用iPhone Simulator 3.2作为基本SDK,但同样的问题发生在SDK 4.0。再次,这与我的设备目标,但不与我的模拟器目标。它与两者,但是,我从iPhone SDK 3.2更新到4.0之前。我也能够通过创建一个只有一个文件和链接的lib的新项目来重现这个错误。但是,在更新XCode和我的SDK之前,lib应该没问题,因为它与模拟器3.2一起工作。

I'm using iPhone Simulator 3.2 as Base SDK, but the same problem occurs with SDK 4.0. Again, this works with my device target but not with my simulator target. It worked with both, though, before I updated from iPhone SDK 3.2 to 4.0. I was also able to reproduce this error by creating a new project with only one file and the linked lib. However, the lib should be okay as it worked with simulator 3.2 before I updated XCode and my SDK.

更多事实:Mac OS X 10.6.3,XCode 3.2.3 64位,iPhone OS 3.2,GCC 4.2

More Facts: Mac OS X 10.6.3, XCode 3.2.3 64-Bit, iPhone OS 3.2, GCC 4.2

任何帮助将非常感激。






<
编辑:

Any help would be highly appreciated.


重新安装SDK 3.2之后,一切正常。必须注意,每个安装都会覆盖/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs文件夹中的SDK。然后我再次尝试重新安装SDK 4.0,并发生与上面相同的错误。我没有更改任何项目,并始终使用3.2作为基本SDK。

After reinstalling SDK 3.2, everything worked as expected again. It must be noted, that the SDKs in folder /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs are overwritten with each installation. I then tried to reinstall SDK 4.0 again and the same error as above occurred. I didn't change anything in my project and always used 3.2 as Base SDK.

因此,问题可能缩小到以下选项:

The problem can therefore possibly be narrowed down to the following options:


  • 苹果改变了。在模拟器SDK 3.2中导致问题

  • XCode 3.2.3中的更改导致问题

  • 错误/缺少编译器标志

我也做了一个文件夹差异(这些标志只会导致更改的SDK或更改的IDE的问题) /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk,用于此文件夹的旧版本和新版本。事实证明,在相同的SDK中实际上有细微的变化。我仍然认为这是一个IDE /编译器标志问题。

I also did a folder diff on /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.2.sdk for both the old and the new version of this folder. It turned out that there are actually minor changes within the "same" SDK. I still think it's an IDE/compiler flag problem, though.

任何人的想法?我不想坚持3.2永远...

Anybody any ideas? I don't want to stick to 3.2 forever...

推荐答案

我终于能够找出哪些标志丢失我的编译器调用构建我的lib。所以,回答我的问题:如果任何人有问题将他/她自己的静态库链接到XCode 3.2.3中的目标(使用iPhoneSimulator3.2.sdk或iPhoneSimulator4.0.sdk),您需要构建您的lib与以下两个标志:

I was finally able to figure out which flags were missing in my compiler call to build my lib. So, to answer my question: If anybody has problems linking his/her own static lib to a target in XCode 3.2.3 (using iPhoneSimulator3.2.sdk or iPhoneSimulator4.0.sdk), you need to build your lib with the following two flags:

-fobjc-abi-version = 2

-fobjc-abi-version=2

-fobjc-legacy-dispatch

-fobjc-legacy-dispatch

再次感谢 PhoneyDeveloper 他的提示

这篇关于链接器错误(只有模拟器)与自己的库后更新到iPhone SDK 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆