Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build failed with: ld: duplicate symbol _OBJC_CLASS_$_Algebra5FirstViewController

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

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

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

What is it all about?

like image 222
Joe Shamuraq Avatar asked May 03 '12 16:05

Joe Shamuraq


4 Answers

It look like the class Algebra5FirstViewController is compile multiple time.

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...

EDIT

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.

like image 70
J_D Avatar answered Nov 09 '22 12:11

J_D


That can happen if the same .m file is referenced multiple times in your target's "Compile Sources" section in "Build Phases". Remove duplicate entries and you should be fine.

like image 31
Andreas Ley Avatar answered Nov 09 '22 14:11

Andreas Ley


also had this problem by declaring a const * NSString in the header file (incorrectly) instead of the implementation file (correctly)

like image 30
toblerpwn Avatar answered Nov 09 '22 14:11

toblerpwn


I got this issue because I accidentally imported the .m instead of the .h. Hope reading this saves someone with same problem some time.

like image 24
user441669 Avatar answered Nov 09 '22 14:11

user441669