2 starwar2012 starwar2012 于 2013.03.25 10:40 提问

苹果O-math链接错误

创建了一个名为ObjCWorkAppMath.mNSObject文件。包含了一些函数在里面,我想在ViewController使用这个类,的那是编译失败返回了错误:

duplicate symbol _OBJC_METACLASS_$_ObjCWorkAppMath in:
    /Users/ctkt/Library/Developer/Xcode/DerivedData/ObjCWorkApp-hgxcjtjhzwxhqxcmxgkpucpfpieq/Build/Intermediates/ObjCWorkApp.build/Debug-iphonesimulator/ObjCWorkApp.build/Objects-normal/i386/ObjCWorkAppMath.o
    /Users/ctkt/Library/Developer/Xcode/DerivedData/ObjCWorkApp-hgxcjtjhzwxhqxcmxgkpucpfpieq/Build/Intermediates/ObjCWorkApp.build/Debug-iphonesimulator/ObjCWorkApp.build/Objects-normal/i386/ObjCWorkAppViewController.o
duplicate symbol _OBJC_CLASS_$_ObjCWorkAppMath in:
    /Users/ctkt/Library/Developer/Xcode/DerivedData/ObjCWorkApp-hgxcjtjhzwxhqxcmxgkpucpfpieq/Build/Intermediates/ObjCWorkApp.build/Debug-iphonesimulator/ObjCWorkApp.build/Objects-normal/i386/ObjCWorkAppMath.o
    /Users/ctkt/Library/Developer/Xcode/DerivedData/ObjCWorkApp-hgxcjtjhzwxhqxcmxgkpucpfpieq/Build/Intermediates/ObjCWorkApp.build/Debug-iphonesimulator/ObjCWorkApp.build/Objects-normal/i386/ObjCWorkAppViewController.o
ld: 2 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

试了很多方法也没解决,请高手帮帮忙,多谢多谢。

#import "ObjCWorkAppViewController.h"
#import "ObjCWorkAppMath.m"

@interface ObjCWorkAppViewController ()

@end

@implementation ObjCWorkAppViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

2个回答

wxcaixiaowei
wxcaixiaowei   2013.08.01 10:55

你的项目多加了一个.m文件

CloveI
CloveI 大神,你能说说是哪个文件被多次引用了吗?可能大家都知道是重复引用了同一个.m,但是是哪个被重引用了还是找不到,解决不了问题
4 年多之前 回复
ipqhjjybj
ipqhjjybj   2013.11.16 17:46

ObjCWorkAppMath ObjCWorkAppViewController 里的重引用解决下就好了

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!