构建失败:ld:重复符号_OBJC_CLASS _ $ _ Algebra5FirstViewController [英] build failed with: ld: duplicate symbol _OBJC_CLASS_$_Algebra5FirstViewController

查看:170
本文介绍了构建失败:ld:重复符号_OBJC_CLASS _ $ _ Algebra5FirstViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过iPhone模拟器运行我的应用时突然出现此错误:

I am getting this error suddenly when running my app via iPhone simulator:


clang:错误:链接器命令失败,退出代码为1 (使用-v查看
调用):

clang: error: linker command failed with exit code 1 (use -v to see invocation):

ld:重复符号_OBJC_CLASS _ $ _ Algebra5FirstViewController in
... / Algebra5-anwcuftojtxtgkfootneeeqhwztj / Build /中间体/ Algebra5.build / Debug-iphonesimulator / Algebra5.build / Objects-normal / i386 / ExercisesViewController.o

... / Algebra5-anwcuftojtxtgkfootneeeqhwztj / Build / Intermediates / Algebra5.build / Debug- iphonesimulator / PSLE
Algebra5.build/Objects-normal/i386/PSLE_Algebra5FirstViewController.o
for architecture i386

ld: duplicate symbol _OBJC_CLASS_$_Algebra5FirstViewController in .../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/Algebra5.build/Objects-normal/i386/ExercisesViewController.o and .../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/PSLE Algebra5.build/Objects-normal/i386/PSLE_Algebra5FirstViewController.o for architecture i386

它有什么关系?

推荐答案

看起来类Algebra5FirstViewController是多次编译的。

It look like the class Algebra5FirstViewController is compile multiple time.

您能否确保.m和.mm仅包含在Xcode的项目源中一次?您也可以通过检查编译日志(右边的最后一个图标,断点图标旁边)确认这一点,并确认它只编译一次。

Can you make sure that the .m and .mm is only included once in your project sources in Xcode? You can also confirm this by checking in the compile log (last icon at the right, next to the breakpoints icon) and see that confirm that it is only compiled once.

此外,如果此类是您链接的库的一部分,并且您有一个具有相同名称的类,则可能会出现相同的错误。

Also, if this class is part of a library that you link against and you have a class with the same name, you could have the same error.

最后,您可以尝试清理和重建,以防旧的目标文件仍然存在并且编译文件中有一些垃圾。以防万一...

Finally, you can try a clean and rebuild, just in case the old object files are still present and there is some junk in the compiled files. Just in case...

编辑

我还注意到第二个引用是在文件中进行的ExercisesViewController。也许这个文件中有一些东西。要么#imported Algebra5FirstViewController文件而不是.h,要么练习ViewController有@implementation(Algebra5FirstViewController)而不是@implementation(ExercisesViewController),或者有一些垃圾用这个文件将用Clean a Rebuild清理。

I also note that the second reference is made in the file for ExercisesViewController. Maybe there is something in this file. Either you #imported the Algebra5FirstViewController file instead of the .h, or the ExercisesViewController has @implementation (Algebra5FirstViewController) instead of @implementation (ExercisesViewController), or there was some junk with this file that will cleaned with a Clean an Rebuild.

这篇关于构建失败:ld:重复符号_OBJC_CLASS _ $ _ Algebra5FirstViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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