简体   繁体   中英

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".

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. I have not yet referred to them in the .cpp files.

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)

This is my first try with non-Objective-C & Cocos2d-x.

The 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. Following the tutorial it will teach you how to implement them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM