We may often encounter such an error during our code writing:
[OBJC]View Plaincopy print?
- <span style="Font-size:32px;color: #ff0000;" >LD: 4 Duplicate symbols for architecture x86_64
- Clang: error:linker command failed with exit code 1 (use-v to see invocation) </span>
Read the cause of the error carefully to find a few key words: "duplicate" and "symbols".
The Chinese meaning of duplicate is " duplicated and duplicated", while symbols means "symbol". That is, it is possible to introduce repetitive things into your project.
I concluded that there are two general situations in which there is a duplicate error:
The first scenario is that you re-import a class or file in your project, which generally occurs when you add a third-party library, and you import the same class again without knowing it.
In the project I created a src folder, the person class has been copied again and added to the project,
At this point, the following error occurred after COMMAND + B was compiled:
Can be seen to report or duplicate error, although duplicate front of the number may not be accurate, but as long as you see duplicate this keyword can go to your project to find whether there is duplicate things are imported.
The second case: The project in the #import introduction of the header file, the #import "XXX.h" written #import "XXX.M". Incorrect introduction of. m header file
I have a class of person in my project, and then I want to initialize an object in the main function, this time I need to introduce the. h file of the person class first. This time I introduced the. m file,
COMMAND + B compiles after errors are found,
You will find that the duplicate is still a mistake. At present, I only found that these two operations will bring this problem, the other if it will bring this problem, welcome everyone to put forward, help me to constantly improve the blog.
iOS duplicate symbols for architecture x86_64 error