Projects > cpp > Issues > Bug #4364

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

"MainScene::MainScene()", referenced from:

Bug #4364 [Closed]
dinesh_kachhot 2014-03-12 05:42 . Updated almost 6 years ago

I am using cocos2d-x 2.2.2 in xcode 5 .

My problem is when i add new c++ class same as HelloWorldScene.cpp .

But when i run it is giving this error

Apple Mech-o Linker Error
"MainScene::MainScene()", referenced from:

This is my MainScene.h File Code

#ifndef __SpaceShooter__MainScene__
#define __SpaceShooter__MainScene__

#include "cocos2d.h"

class MainScene : public cocos2d::CCLayer{
    bool init();
    static cocos2d::CCScene* scene();


#endif /* defined(__SpaceShooter__MainScene__) */

And this is my MainScene.cpp file Code

#include "MainScene.h"


CCScene* MainScene::scene()
    // 'scene' is an autorelease object
    CCScene *scene = CCScene::create();

    // 'layer' is an autorelease object
    MainScene *layer = MainScene::create();

    // add layer as a child to scene

    // return the scene
    return scene;

bool MainScene::init(){

    return true;

Please Help me to get out of here.....

dabingnn 2014-03-12 06:43
  1. The reason of the link error is that you have not implemented MainScene constructor function. You just declared in header file.
  2. Please send a forum post first, this is not an issue of cocos2d. A post in forum is better. Thank you. 2014-10-08 02:49

Redmine issue system is closed, we are using github issue system instead.

This issue was moved to

Atom PDF

Start date:2014-03-12
Due date:
% Done:


Category:android, ios, wp8
Target version:-