Xcode 项目中的重复符号构建错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3376926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Duplicate symbol build error in Xcode project
提问by node ninja
When I try to build my project I get the following error.
当我尝试构建我的项目时,出现以下错误。
ld: duplicate symbol .objc_class_name_GLFunView in /Users/gin/Documents/development/GLFun/build/GLFun.build/Debug-iphonesimulator/GLFun.build/Objects-normal/i386/GLFunView-7A51E8797CBB3D72.o and /Users/gin/Documents/development/GLFun/build/GLFun.build/Debug-iphonesimulator/GLFun.build/Objects-normal/i386/GLFunView-7A51E8797CBB3D72.o
ld:/Users/gin/Documents/development/GLFun/build/GLFun.build/Debug-iphonesimulator/GLFun.build/Objects-normal/i386/GLFunView-7A51E8797CBB3D72.o 和 /Users/gin/Documents 中的重复符号 .objc_class_name_GLFunView /development/GLFun/build/GLFun.build/Debug-iphonesimulator/GLFun.build/Objects-normal/i386/GLFunView-7A51E8797CBB3D72.o
What is this error about? How can I track down where the error is? XCode usually highlights the code that has problems, but for this error it's not showing anything? It doesn't have anything to do with Interface Builder does it?
这个错误是关于什么的?我怎样才能追踪错误在哪里?XCode 通常会突出显示有问题的代码,但是对于此错误,它没有显示任何内容?它与Interface Builder没有任何关系,是吗?
My research indicates that this might be caused by including something twice, but I don't understand how that's possible since I'm not using any #include statements, I'm only using #import statements.
我的研究表明这可能是由于包含两次内容引起的,但我不明白这是怎么可能的,因为我没有使用任何 #include 语句,我只使用 #import 语句。
Here's some more of the build output:
这是更多的构建输出:
Ld build/Debug-iphonesimulator/GLFun.app/GLFun normal i386 cd /Users/gin/Documents/development/GLFun setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/gin/Documents/development/GLFun/build/Debug-iphonesimulator -F/Users/gin/Documents/development/GLFun/build/Debug-iphonesimulator -filelist /Users/gin/Documents/development/GLFun/build/GLFun.build/Debug-iphonesimulator/GLFun.build/Objects-normal/i386/GLFun.LinkFileList -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework CoreGraphics -framework OpenGLES -framework QuartzCore -o /Users/gin/Documents/development/GLFun/build/Debug-iphonesimulator/GLFun.app/GLFun
ld build/Debug-iphonesimulator/GLFun.app/GLFun normal i386 cd /Users/gin/Documents/development/GLFun setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr /bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform /Developer/SDKs/iPhoneSimulator3.1.3.sdk -L/Users/gin/Documents/development/GLFun/build/Debug-iphonesimulator -F/Users/gin/Documents/development/GLFun/build/Debug-iphonesimulator -filelist /Users /gin/Documents/development/GLFun/build/GLFun.build/Debug-iphonesimulator/GLFun.build/Objects-normal/i386/GLFun.LinkFileList -mmacosx-version-min=10。5 -framework Foundation -framework UIKit -framework CoreGraphics -framework OpenGLES -framework QuartzCore -o /Users/gin/Documents/development/GLFun/build/Debug-iphonesimulator/GLFun.app/GLFun
回答by Mark
I ran into the same problem today. It turned out to be a typo in an #import
statement. I accidentally included the .m
file instead of the header:
我今天遇到了同样的问题。结果证明是#import
声明中的一个错字。我不小心包含了.m
文件而不是标题:
#include "MyClass.m"
instead of:
代替:
#include "MyClass.h"
回答by Lily Ballard
My guess is you're @implementing GLFunView twice in the same file (GLFunView.m). Perhaps you meant to implement GLFunView and then implement a category on it, and forgot the category name?
我的猜测是你在同一个文件 (GLFunView.m) 中 @implementing GLFunView 两次。也许您打算实现 GLFunView 然后在其上实现一个类别,而忘记了类别名称?