iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – Xcode重复符号错误大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述@H_772_4@ 我得到“Apple Mach-O Linker(Id)Error”: ld: duplicate symbol _matrixIdentity in /BlahBlah/Corridor.o and /Blahblah/Drawable.o for architecture i386 “Corridor”类扩展了“Drawable”类,“_ matrixIdentity”在文件“Utils.h”中
我得到“Apple Mach-O Linker(Id)Error”

ld: duplicate symbol _matrixIdentity in /BlahBlah/Corridor.o and /Blahblah/Drawable.o for architecture i386

“Corridor”类扩展了“Drawable”类,“_ matrixIdentity”在文件“Utils.h”中定义和实现.以下是我的头文件的顶行:

Drawable.h

#import <Foundation/Foundation.h>
#import "Utils.h" 
@interface Drawable : NSObject
...

Corridor.h

#import <Foundation/Foundation.h>
#import "Drawable.h"
@interface Corridor : Drawable
...

我已经检查过是否有“.m”导入而不是“.h”,一切都是正确的.任何想法,什么可能导致这个问题?

编辑:从“Utils.h”发布代码

#import <Foundation/Foundation.h>    
...
#pragma mark -
#pragma mark DeFinitions

typedef float mat4[16];

#pragma mark -
#pragma mark Functions
void matrixIdentity(mat4 m)

{
m[0] = m[5] = m[10] = m[15] = 1.0;
m[1] = m[2] = m[3] = m[4] = 0.0;
m[6] = m[7] = m[8] = m[9] = 0.0;
m[11] = m[12] = m[13] = m[14] = 0.0;
}
...

我只是在我的两个类的方法中引用“mat4”定义.另外,“matrixIdentity”只是这个文件中的第一个函数,可能是问题没有在实现中.

解决方法@H_404_39@
C/C++ / Objective-C与Java,C#,Ruby,Python的差异……

划分文件.

标题&毫米

不要使用#include(可能包括很多次)

使用#import …(包含一次)

Utils.h

#ifndef __utils_h__ // <<< avoid multiple #include
#define __utils_h__ // <<< avoid multiple #include
#import <Foundation/Foundation.h>    
...
#pragma mark -
#pragma mark DeFinitions

typedef float mat4[16];

#pragma mark -
#pragma mark Functions
extern void matrixIdentity(mat4 m);

#endif // __utils_h__ <<< avoid multiple #include

Utils.mm

#import "Utils.h"

void matrixIdentity(mat4 m)
{
m[0] = m[5] = m[10] = m[15] = 1.0;
m[1] = m[2] = m[3] = m[4] = 0.0;
m[6] = m[7] = m[8] = m[9] = 0.0;
m[11] = m[12] = m[13] = m[14] = 0.0;
}
...

大佬总结

以上是大佬教程为你收集整理的iphone – Xcode重复符号错误全部内容,希望文章能够帮你解决iphone – Xcode重复符号错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。