1. 程式人生 > >error LNK2019: 無法解析的外部符號 該符號在函式 中被引用

error LNK2019: 無法解析的外部符號 該符號在函式 中被引用

#include "cocos2d.h"

class GameLayer : public cocos2d::CCLayer
{
public:
	GameLayer();
	~GameLayer();

	virtual bool init();
    CREATE_FUNC(GameLayer);

    void initTileMap();
	cocos2d::CCTMXTiledMap *_tileMap;
};
#include "GameLayer.h"
#include "cocos2d.h"
/****/
GameLayer::GameLayer()
{
	_tileMap = NULL;
}
/**
GameLayer::~GameLayer()
{
	
}**/

bool GameLayer::init()
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(!CCLayer::init());

        this->initTileMap();
        
        bRet = true;
    } while (0);

    return bRet;
}

void GameLayer::initTileMap()
{
	_tileMap = cocos2d::CCTMXTiledMap::create("pd_tilemap.tmx");
    CCObject *pObject = NULL;
    CCARRAY_FOREACH(_tileMap->getChildren(), pObject)
    {
        cocos2d::CCTMXLayer *child = (cocos2d::CCTMXLayer*)pObject;
        child->getTexture()->setAliasTexParameters();
    }
    this->addChild(_tileMap, -6);
}

產生錯誤:

1>GameLayer.obj : error LNK2019: 無法解析的外部符號 "public: virtual __thiscall GameLayer::~GameLayer(void)" ([email protected]@[email protected]),該符號在函式 "public: virtual void * __thiscall GameLayer::`scalar deleting destructor'(unsigned int)" ([email protected]@[email protected]) 中被引用

錯誤的原因是在申明的解構函式,沒有在cpp裡面實現

還有很多種,無法解析外部符號的錯誤,多數都是 在標頭檔案中申明的函式方法,沒有在cpp中實現,而導致的

2-》

關於LINK : fatal error LNK1168: 無法開啟***.exe****

 開啟工作管理員,找到***.exe 把這個程序關掉就可以了。
或者開始執行,輸入taskill -im ***.exe -f 回車就行了,也是結束程序***.exe。