I had a class called ReportsViewController in my iPhone app. I wanted to restore it form an older version of the class which I had copied to a text file. I copied and pasted the whole thing, and now everything is going wrong. I get the following error:
ld: duplicate symbol _OBJC_METACLASS_$_ReportsViewControllers in /Users/myname/Library/Developer/Xcode/DerivedData/TestGA-gipaszaocsrbkwashqjghthtsoda/Build/Intermediates/TestGA.build/Release-iphoneos/TestGA.build/Objects-normal/armv6/ReportsViewControllers.o and /Users/myname/Library/Developer/Xcode/DerivedData/TestGA-gipaszaocsrbkwashqjghthtsoda/Build/Intermediates/TestGA.build/Release-iphoneos/TestGA.build/Objects-normal/armv6/MasterGA.o for architecture armv6
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
How can I fix this?
Judging by the error, you've got two declarations of ReportsViewControllers. You need to find the one that you don't want and delete it.
Either there are two class-files or you "dubble-pasted" it, means there are two #implementaion MyController
Related
I am facing a critical problem here, Xcode throws strange exception while building it's
"
duplicate symbol _selected in:
/Users/mhgaber/Library/Developer/Xcode/DerivedData/اProject-Name-aopcbghvorqhdwbyudzqsyhtekcu/Build/Intermediates/Project-Name.build/Debug-iphonesimulator/Project-Name.build/Objects-normal/i386/ClassX.o
/Users/mhgaber/Library/Developer/Xcode/DerivedData/Project-Name-aopcbghvorqhdwbyudzqsyhtekcu/Build/Intermediates/Project-Name.build/Debug-iphonesimulator/Project-Name.build/Objects-normal/i386/ClassY.o
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I searched a lot but I didn't find anything help me please
Look at both the files for ClassX and ClassY - What targets are they included in? Basically the _selected method is duplicated in both of them. I am going to guess this is a plain C method that happens to be named the same in both files. Try renaming _selected in one of the files.
In my case, I was declaring a const in a header file, which worked fine when building and running on the device (iPhone 5), however when attempting to simulate a 4S, all of a sudden I had some 300 "duplicate symbols".
It turns out I needed to also mark the const as static and the issue went away. Presumably it was trying to redefine the constant every time the header was referenced. The compiler isn't smart enough to just make constants static? Didn't think that would be necessary, but I guess it is.
const CGFloat kTitleAnimateDistance = 50.f;
Needed to be:
const static CGFloat kTitleAnimateDistance = 50.f;
Some time you accidentally importing the .m file instead of the .h due to which this error comes. Please check and If this is not the reason, then perform the following steps
1- Check Build phases in Target settings.
2- Go to compile source section.
3- Check if any file exists twice or once.
4- If file exist twice delete one.
5- Build again.
I was having the same problem and #dtrotzjr 's answer gave me a hint as to what could be causing it.
In my case I had a plain C void function in my framework (which xcode was complaining about as a duplicate symbol) and i needed to declare it as static void
I had the same issue. I was including a .h file with a number of const strings, methods and a struct. When I changed them all to static except the only mutable variable I wanted, it compiled just fine.
I got this error when i tried to build:
"duplicate symbol __Z8ERRCHECK11FMOD_RESULT in:
/Users/codemenmini2012-2/Library/Developer/Xcode/DerivedData/MagicSleepFullVersion-agxulkdijnxbqmbuigucmrczufyw/Build/Intermediates/MagicSleepFullVersion.build/Debug-iphonesimulator/MagicSleepFullVersion.build/Objects-normal/i386/MagicSleepViewController.o
/Users/codemenmini2012-2/Library/Developer/Xcode/DerivedData/MagicSleepFullVersion-agxulkdijnxbqmbuigucmrczufyw/Build/Intermediates/MagicSleepFullVersion.build/Debug-iphonesimulator/MagicSleepFullVersion.build/Objects-normal/i386/MagicSleepViewControllerIpad.o
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)"
How to solve this guys?
The error may occur when you copy and paste the contents of one file to another file with its interface name which means two classes with same interface name.
In your code you have two different files with the same Interface name.
For me this error happened because I was dumb enough to copy the whole folder of a downloaded lib to the project and there was a demo project inside it. So I had two main.m files. Hope this helps anyone!
In my case I had accidently imported .m file instead if .h file. Hope it helps someone for this kinda silly mistake.
when you create bool variables with same name in two different classes then this error comes.
"duplicate symbol __Z8ERRCHECK11FMOD_RESULT in"
so check your both classes
MagicSleepViewController.m and
MagicSleepViewControllerIpad.m.
for same bool variables.
Change the bool variable name, your problem will solve.
Looks like you have at least one (probably more) symbol (or methods, functions, etc.) that's duplicated between MagicSleepViewController.m and MagicSleepViewControllerIpad.m.
You need to either 1) change the names of one set of duplicated methods or 2) figure out a way to merge MagicSleepViewController.m & MagicSleepViewControllerIpad.m so the same code will work on both iPhones and iPads (e.g. using run time conditionals or whatever to determine what kind of device your code is currently running on).
I had #defines placed in two files that were exactly the same... DOH.
For me, a search in the finder for the named duplicates has helped.
The problem in my case was caused due to multiple references in the "Compile Sources". So I deleted one from Project->Build Phases-> Compile Sources.
I am developing an iPad app in which I have included 2 third party static libraries. The names of the object files in these 2 libraries are same. On building the app I am getting
"Apple Mach -O (id) error"
because of the same names of the object files in those 2 libraries.
How to solve this problem?
Error looks like:
ld: duplicate symbol _T_strcpy in /Users/indiait-supportservices/Desktop/untitled folder/Universal/lib/simulator/libSecurIDLib.a(mem.o) and /Users/indiait-supportservices/Library/Developer/Xcode/DerivedData/ReceiverForiOS-aqpprpcivvjjadbsutqqmtjsoczk/Build/Intermediates/ReceiverForiOS.build/Debug-iphonesimulator/myApp iPad.build/Objects-normal/i386/pdcrypte2.o for architecture i386
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2
failed with exit code 1.
Are you building for one architecture? If you are building for multiple architectures and use the -all_load linker flag, this breaks the linker's ability to ignore symbols that are defined for multiple architectures. As a test, try building just for armv6 and see if the error goes away.
There is a good blog post here and a similar question discussed here.
Finally, you can add the following env var to debug problems with overriding categories:
OBJC_PRINT_REPLACED_METHODS=YES. This will log which method names have been overridden by categories, just in case that is the issue.
It looks like you have two modules defining the same function, one in libSecurIDLib.a(mem.o) and pdcrypte2.o. These should be in their own namespaces (C++) or they should be prefixed so they don't collide (C).
There are work arounds if that's impossible, but it's better name things safely.
Trying to compile a iPhone/iPad application with SDK3.2 and am getting this error:
Undefined symbols:
"_main", referenced from:
Start in crt1.10.5.o
Symbol(s) not found
Collect2: Id returned 1 exit status
I think it's telling me that it's somehow trying to work with code from another SDK but searching the web has not provided any clear answers.
Anyone able to guide me on this and what to look for?
It looks like you haven't provided a main function in any of your source files. The crt object file is most likely the startup code which sets up your environment then calls main (CRT usually stands for C runtime, when it's not being used to mean Cathode Ray Tube, which it shouldn't any more, that being dead technology and all).
The Undefined symbols: "_main" ... simply means that the linker has discovered crt1.10.5.o needs the _main symbol satisfied and none of the files provided are satisfying it.
Short of seeing the actual linker command line, we can't be certain what's being included. You should check your source code and confirm or deny the existence of main()? And that it's inluded in the build?
There appears to be several possible causes.
I ran into this problem when the Perform Single-Object Prelink build option was checked
(GENERATE_MASTER_OBJECT_FILE = YES).
I got this when I opened a Swift project in Xcode 5. When I opened it in Xcode 6, it worked fine.
I've addeda category to NSString. I've tried to place the code in my appDelegate.h and it works. However, I've tried placing it in another .h file that I included from .pch file so that this category can be used project wide. However I kept getting the following error:
ld: duplicate symbol .objc_category_name_NSString_StringTrim in ....AppDelegate.o and .....main.o
collect2: ld returned 1 exit status
The weird thing is, I only get this error when I compile for the simulator but not device! Any ideas?
I always declare categories in Foo+Category.h and Foo+Category.m, for example NSString+Hashing.h and NSString+Hashing.m. In the source that uses the category I then import the Foo+Category.h and everything works wonders. The good thing about this solution is that the category gets mentioned explicitly in the code that uses it, so that the magic is apparent.