Linker Command Failed with exit code 1: duplicate

2019-06-15 14:04发布

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?

4条回答
该账号已被封号
2楼-- · 2019-06-15 14:41

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.

查看更多
forever°为你锁心
3楼-- · 2019-06-15 14:41

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;
查看更多
狗以群分
4楼-- · 2019-06-15 14:41

I ran into this same error while trying to integrate a few frameworks into my app.

First I was using Sparrow - a graphics library, and by default I had a main.m file, things were fine until I tried to integrate Parse which also depended on the FacebookSDK. Within the FacebookSDK folders there is a Sample app called Scrumptious with a main.m as well which was the source of my problems. I removed the sample apps directory and everything built fine.

查看更多
劳资没心,怎么记你
5楼-- · 2019-06-15 14:45

You probably have double _velocityX in a header file included by both Level1ViewController.c and Level2ViewController.c, when the header should have extern double _velocityX, and exactly one of the .c files should have double _velocityX. (Assuming the type of _velocityX is double, which seemed reasonable, and also assuming this is either C or C++ and not Fortran or something).

查看更多
登录 后发表回答