链接器错误 - 项目未完全清理?

发布于 2024-12-05 03:34:20 字数 834 浏览 0 评论 0原文

我要在这里提前道歉。我正在工作的项目有几项保密协议,因此我无法像通常希望的那样具体。

我正在开发一个 iOS 项目,其中包含 .h 和 .a 文件形式的预编译库。我开始使用该库的特定版本进行开发,一切正常。此后他们发布了一个新版本,我需要该版本来实现特定的新功能。

在新旧版本之间,一些函数名称发生了变化。当我更新代码以调用新方法时,我在编译时收到 Apple Mach-O 链接器错误:(名称已更改以保护无辜者)

Undefined symbols for architecture armv7:
  "methodName", referenced from:
    myMethod()      in MyClass.o
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status

我知道它看起来只是不包含armv7代码,但这实际上是一个转移注意力的事情。如果我将项目和目标的架构构建设置设置为“标准(armv6 armv7)”,我会得到相同的链接器错误,只不过它会显示“armv6”。

问题是,我可以将新的 .h 和 .a 文件放入新项目中并调用相同的方法,而不会出现链接器错误!

我有一种感觉,有一些东西没有被清理,并且它正在尝试针对旧的 .a 文件进行编译。我在 Snow Leopard 上使用 Xcode 4.1。我尝试从项目中删除该文件,从目标的Build Phases下的Link Binary With Libraries部分删除.a文件,清理,添加回.a文件。一个文件并重建,我仍然收到错误。我在这里开始发疯。

I'm going to apologize in advance here. The project I'm working is under a couple NDAs so I'm not going to be able to be as specific as I would normally want to.

I'm working on an iOS project that includes a pre-compiled library in the form of a .h and .a file. I started development with a particular version of this library and everything was working fine. They've since released a new version that I need for a particular new feature.

Between the old and new versions, several of the function names have changed. When I update my code to call the new methods, I'm getting an Apple Mach-O Linker Error at compile time: (Names have been changed to protect the innocent)

Undefined symbols for architecture armv7:
  "methodName", referenced from:
    myMethod()      in MyClass.o
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status

I know it looks like it just doesn't include armv7 code, but that's actually a red herring. If I set the architecture build setting for both the project and target to Standard (armv6 armv7), I get the same linker error, except it'll say armv6.

The problem is, I can put the new .h and .a files in a new project and call this same method and not get the linker error!

I have a feeling that there's something that isn't getting cleaned and it's trying to compile against the old .a file. I'm using Xcode 4.1 on Snow Leopard. I've tried removing the file from the project, deleting the .a file from the Link Binary With Libraries section under Build Phases for the target, cleaning, adding back the .a file and rebuilding and I still get the error.I'm starting to go crazy here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明明#如月 2024-12-12 03:34:20

好的——我找到了罪魁祸首!当然,它是在“构建设置”中。

当我切换到新版本时,我将新库放在旧版本旁边的文件夹中,以防万一我必须在某个时候切换回来。显然,当我删除旧版本时,它并没有从目标的构建设置中的库搜索路径中删除旧版本 .a 文件的路径。删除旧路径,一切恢复正常。

OK - I found the culprit! Naturally, it was in Build Settings.

When I switched to the new version, I put the new library in a folder next to the old one, in case I had to switch back at some point. Apparently, when I removed the old version, it did not remove the path to the old version of the .a file from Library Search Paths in the build settings for the target. Deleted the old path, everything is working again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文