没有重复文件:链接器命令失败,退出代码为1(使用-v查看调用)

时间:2013-07-11 21:28:29

标签: objective-c linker-errors

我收到错误“链接器命令失败,退出代码为1(使用-v查看调用)” 在我的程序上,我不知道该怎么做。 是的,我知道还有其他问题,我读了它们并尝试了不同的解决方案,但我认为问题是不同的。 我已经检查了存储在桌面上的项目文件和Library / Developer中的项目文件,但是我找不到任何重复的类,即使它告诉我它。

如果你需要,我也可以给你我的代码,但希望我不必这样做。 谢谢! :d

完整错误报告: Ld / Users / ethen / Library / Developer / Xcode / DerivedData / ProjAllele-asuihysyexvjvmdsgfladthghavb / Build / Products / Debug / ProjAllele normal x86_64     cd / Users / ethen / Desktop / ProjAllele     setenv MACOSX_DEPLOYMENT_TARGET 10.8         /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10。 8.sdk -L / Users / ethen / Library / Developer / Xcode / DerivedData / ProjAllele-asuihysyexvjvmdsgfladthghavb / Build / Products / Debug -F / Users / ethen / Library / Developer / Xcode / DerivedData / ProjAllele-asuihysyexvjvmdsgfladthghavb / Build / Products / Debug -filelist /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/ProjAllele.LinkFileList -mmacosx-version-min = 10.8 -fobjc-arc -fobjc-link-runtime -framework Foundation -o / Users / ethen / Library / Developer / Xcode / DerivedData / ProjAllele-asuihysyexvjvmdsgfladthghavb / Build / Products / Debug / ProjAllele

duplicate symbol _OBJC_METACLASS_$_Organism in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Organism.o
duplicate symbol _OBJC_CLASS_$_Organism in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Organism.o
duplicate symbol _OBJC_METACLASS_$_Organism in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Pea.o
duplicate symbol _OBJC_CLASS_$_Organism in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Pea.o
duplicate symbol _OBJC_METACLASS_$_Plant in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Pea.o
duplicate symbol _OBJC_CLASS_$_Plant in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Pea.o
duplicate symbol _OBJC_METACLASS_$_Organism in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Plant.o
duplicate symbol _OBJC_CLASS_$_Organism in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Plant.o
duplicate symbol _OBJC_METACLASS_$_Plant in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Plant.o
duplicate symbol _OBJC_CLASS_$_Plant in:
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/main.o
    /Users/ethen/Library/Developer/Xcode/DerivedData/ProjAllele-asuihysyexvjvmdsgfladthghavb/Build/Intermediates/ProjAllele.build/Debug/ProjAllele.build/Objects-normal/x86_64/Plant.o
ld: 10 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

1 个答案:

答案 0 :(得分:0)

在评论中你写道:“main.m进口Pea.h Pea.h进口Plant.m,......”。

有问题。 “Pea.h”必须输入“Plant.h”,而不是“Plant.m”。

否则“Plant.m”中的Plant类编译在导入“Pea.h”的所有源文件中, 例如在“main.m”中,导致重复的定义错误。