Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linker Command Failed with exit code 1: duplicate symbol

ld: duplicate symbol _velocityX in \
/Users/Student/Library/Developer/Xcode/DerivedData/finalproject-ffzevekmatxvhrgisgeleoijyllr/Build/Intermediates/finalproject.build/Debug-iphonesimulator/finalproject.build/Objects-normal/i386/Level2ViewController.o \
and \
/Users/Student/Library/Developer/Xcode/DerivedData/finalproject-ffzevekmatxvhrgisgeleoijyllr/Build/Intermediates/finalproject.build/Debug-iphonesimulator/finalproject.build/Objects-normal/i386/Level1ViewController.o \
for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

UPDATE: added \ + newlines for readability

I have no clue what is wrong with my project, can anyone help?

like image 615
user1563809 Avatar asked Jul 30 '12 18:07

user1563809


People also ask

What does 1 duplicate symbol for architecture x86_64 mean?

Well, it means we're trying to link the same symbol name (in our case, a method) from two (or more) different source files. The fix was easy: rename one of the methods by updating the header file, the source file (. c or .

What does duplicate symbol mean in C++?

Duplicate symbols occur when you have both added an implementation file (. cpp) to your project and #included it. This way, the implementation file (. cpp) gets compiled twice: once as a module in your project (as it is added to your project) and subsequently as a piece of #included code.

What is clang error?

clang: error: linker command failed with exit code 1 (open frameworks) exitCode1. This means you have two files which have a function called "main" in them -- the compiler compiles all the code fine, but when it goes to link, it sees two object symbols that have the same name.


2 Answers

I had this same error, it was because I defined a constant with the same name in two separate .m files. Once I changed the name in one of them, it compiled.

For example in my ViewController.m I had:

#import "ViewController.h"
const int IPHONE4 = 480;

and in my Menu.m:

#import "Menu.h"
const int IPHONE4 = 480;

I changed my Menu.m to:

#import "Menu.h"
const int IPHONE4H = 480;
like image 188
Ali Avatar answered Nov 07 '22 15:11

Ali


I had same problem. But it was my fault. :). You might have writen a #import file.m instead of #import file.h. So Compiles Resource will duplicate symbol file.o. - That's it! ^^ To see it, You remove that error file, build --> Show error row --> then recopy it.

like image 23
Chu Bao .Dev Avatar answered Nov 07 '22 17:11

Chu Bao .Dev