【发布时间】:2014-05-20 16:50:58
【问题描述】:
我目前正在 Xcode for Mac 中开发一个应用程序。我通常很擅长在问题出现时找出解决问题的方法,但一个错误总是让我着迷。当我在两个单独的类中包含相同的标题时,我得到了重复的符号错误。我的代码如下所示:
Utilities.h
#ifndef __UTILITIES_H
#define __UTILITIES_H
#import <Foundation/Foundation.h>
#import "Path.h"
#import "Matrix.h"
#import "Shader.h"
#import "Texture.h"
#endif
BlaineEntity.h
#import "Utilities.h"
@interface BlaineEntity : NSObject
{
GLuint blaineID[3];
GLfloat modelMat[16], rotMat[16], transMat[16];
GLuint blaineVID[1];
GLuint textureID;
GLint uniform_mytexture;
Matrix *matrix;
Texture *tex;
}
- (void)render;
- (void)update;
- (void)setup;
- (void)setLocation:(GLfloat)x y:(GLfloat)y z:(GLfloat)z Rotx:(GLfloat)rx Roty:(GLfloat)ry Rotz:(GLfloat)rz;
- (void)translate:(GLfloat)forward lr:(GLfloat)lr ud:(GLfloat)ud;
@end
TempEntity.h
#import "Utilities.h"
@interface TempEntity : NSObject
{
GLuint tempID[3];
GLfloat modelMat[16], rotMat[16], transMat[16];
GLuint tempVID[1];
GLuint texID;
GLint uniform;
Matrix *matrix;
Texture *tex;
}
- (void)Render;
- (void)Update;
- (void)Setup;
- (void)SetLocation:(GLfloat)x y:(GLfloat)y z:(GLfloat)z Rotx:(GLfloat)rx Roty:(GLfloat)ry Rotz:(GLfloat)rz;
- (void)Translate:(GLfloat)forward lr:(GLfloat)lr ud:(GLfloat)ud;
@end
如何避免链接器错误...
编辑
这是链接器错误
duplicate symbol _started in:
/Users/sonardev/Library/Developer/Xcode/DerivedData/Blaine's_Adventures:_The_Lost_Mark-eyovjgtlqhbbcoeukwivyitbhqly/Build/Intermediates/Blaine's Adventures: The Lost Mark.build/Debug/Blaine's Adventures: The Lost Mark.build/Objects-normal/x86_64/TempEntity.o
/Users/sonardev/Library/Developer/Xcode/DerivedData/Blaine's_Adventures:_The_Lost_Mark-eyovjgtlqhbbcoeukwivyitbhqly/Build/Intermediates/Blaine's Adventures: The Lost Mark.build/Debug/Blaine's Adventures: The Lost Mark.build/Objects-normal/x86_64/BlaineEntity.o
ld: 1 duplicate symbol for architecture x86_64
【问题讨论】:
-
发布链接器错误。
-
@Zaph 好的,我编辑它以添加链接器错误
-
您能否将
started或_started的定义发布在.h中导入的Utilities.h文件之一中? -
有一个重复符号:
_started。它可能是一个名为started的方法。搜索那个。
标签: objective-c xcode macos clang linker-errors