[英]Cocos2d-x - clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am getting these messages in Cocos2d-x (2.1.5) when doing a tutorial (Air Hockey) from the book "Cocos2d-x Beginner Guide". 从《 Cocos2d-x入门指南》一书中进行教程(空中曲棍球)时,我在Cocos2d-x(2.1.5)中得到了这些消息。
I have checked all the "#include", BuildPhases etc. in Xcode as well as performed "Validate Settings" in "Compile Sources" (approx. 250 files) and screened internet and would appreciate anyones view on this. 我已经检查了Xcode中的所有“ #include”,BuildPhases等,并在“编译源代码”(约250个文件)中执行了“验证设置”并屏蔽了Internet,希望有人对此表示赞赏。 I have not yet referred to them in the .cpp files. 我尚未在.cpp文件中引用它们。
BTW, the Cocos2d-x version in the book is not the same as the one i use, I have checked the books website and found this from the author: the Authors comment on the releases for the tutorial(s) 顺便说一句,本书中的Cocos2d-x版本与我使用的版本不同,我检查了图书网站并从作者那里找到了这一点: 作者对本教程的发行版发表了评论
This is my first try with non-Objective-C & Cocos2d-x. 这是我第一次尝试使用非Objective-C和Cocos2d-x。
The GameLayer.h: GameLayer.h:
#ifndef __GAMELAYER_H__
#define __GAMELAYER_H__
#define GOAL_WIDTH 400
#include "cocos2d.h"
#include "GameSprite.h"
using namespace cocos2d;
class GameLayer : public cocos2d::CCLayer {
GameSprite *_player1;
GameSprite *_player2;
GameSprite *_ball;
CCArray *_players;
CCLabelTTF *_player1ScoreLabel;
CCLabelTTF *_player2ScoreLabel;
CCSize _screenSize;
int _player1Score;
int _player2Score;
void playerScore (int player);
public:
~GameLayer();
virtual bool init();
static CCScene *scene();
CREATE_FUNC(GameLayer);
virtual void ccTouchesBegan(CCSet* pTouches, CCEvent* event);
virtual void ccTouchesMoved(CCSet* pTouches, CCEvent* event);
virtual void ccTouchesEnded(CCSet* pTouches, CCEvent* event);
void update (float dt);
};
#endif // __GAMELAYER_H__
The messages: 消息:
clang: warning: argument unused during compilation: '-websockets'
Undefined symbols for architecture i386:
"GameLayer::ccTouchesBegan(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"GameLayer::ccTouchesEnded(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"GameLayer::ccTouchesMoved(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"GameLayer::update(float)", referenced from:
vtable for GameLayer in GameLayer.o
"non-virtual thunk to GameLayer::ccTouchesBegan(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"non-virtual thunk to GameLayer::ccTouchesEnded(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
"non-virtual thunk to GameLayer::ccTouchesMoved(cocos2d::CCSet*, cocos2d::CCEvent*)", referenced from:
vtable for GameLayer in GameLayer.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You didn't implement these functions in your GameLayer.ccp. 您没有在GameLayer.ccp中实现这些功能。 Following the tutorial it will teach you how to implement them. 遵循本教程,它将教您如何实现它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.