Duplicate Symbol Error for architecture i386

主宰稳场 提交于 2019-12-23 15:22:42

问题


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?


回答1:


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.




回答2:


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!




回答3:


In my case I had accidently imported .m file instead if .h file. Hope it helps someone for this kinda silly mistake.




回答4:


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.




回答5:


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




回答6:


I had #defines placed in two files that were exactly the same... DOH.




回答7:


For me, a search in the finder for the named duplicates has helped.




回答8:


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.



来源:https://stackoverflow.com/questions/14746699/duplicate-symbol-error-for-architecture-i386

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!