c++ - Cocos2d-x-clang : error: linker command failed with exit code 1 (use -v to see invocation)

标签 c++ ios6 xcode4.5 cocos2d-x

我在 Cocos2d-x (2.1.5) 中收到来自“Cocos2d-x 初学者指南”一书中的教程(空中曲棍球)时收到这些消息。

我已经检查了 Xcode 中的所有“#include”、BuildPhases 等,并在“编译源”(大约 250 个文件)中执行了“验证设置”,并筛选了互联网,非常感谢任何人对此的看法。我还没有在 .cpp 文件中引用它们。

顺便说一句,书上的Cocos2d-x版本和我用的不一样,我查了书网,从作者那里找到的:the Authors comment on the releases for the tutorial(s)

这是我第一次尝试使用非 Objective-C 和 Cocos2d-x。

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__

消息:

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)

最佳答案

您没有在 GameLayer.ccp 中实现这些功能。按照本教程,它将教您如何实现它们。

关于c++ - Cocos2d-x-clang : error: linker command failed with exit code 1 (use -v to see invocation),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18861695/

相关文章:

ios - 在我的 iPhone 中显示当前位置

带括号和不带括号的 C++ 类初始化

iphone - 如何使用 googleAPI 在 UIWebView 中获取方向?

iphone - 使用 UIPrintInteractionController 打印 PDF ios 5 有效,但在 ios 6 中不起作用并使我的应用程序崩溃

ios - 如何为新项目指定默认的最低 iOS 版本?

iphone - XCode 4.5 (4G182) + iPhone 5 iOS6 - 选择具有受支持架构的目标以便在此设备上运行

c++ - 试图打印出数组,但它在打印前进入了一个新行

c++ - Google Benchmark,如何只调用一次代码?

c++ - 如何将所有权从 C++ std::vector<char> 转移到 char *pointer

xcode - MKMapView setRegion : animated: crashes the app (edited)