6
votes

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

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?

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.

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

2
You must be including something twice because the paths are the same.. does it say "Included from" in any of the build output? - jtbandes
Includes almost never cause linker errors. This one might be triggered by multiple includes if you have an @implementation in a header file… but if that's the case, then you have other problems. - Peter Hosey
I searched the whole project for @implementation and didn't find a single instance of it. - node ninja
The build output doesn't say "included from" anywhere. - node ninja
Peter, if the problem was an import that picked up an @implementation (and someone on #iphonedev had that very problem last week, they imported a .m by accident), the linker error would have listed two separate object files. - Lily Ballard

2 Answers

23
votes

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:

#include "MyClass.m"

instead of:

#include "MyClass.h"
3
votes

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?