高手救命·关于 error LNK2019: 无法解析的外部符号

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了高手救命·关于 error LNK2019: 无法解析的外部符号相关的知识,希望对你有一定的参考价值。

#ifndef __BLOCK_H__
#define __BLOCK_H__

#include "cocos2d.h"
#include "GameSprite.h"

USING_NS_CC;
enum
kBlockGap,//块间隔
kBlock1,
kBlock2,
kBlock3,
kBlock4

;
class Block : public GameSprite
//屏幕宽高
CCSize _screenSize;

void initBlock(void);
public:
CC_SYNTHESIZE(int, _type, Type);
Block();
~Block();
static Block * create();
void setupBlock (int width, int height, int type);
inline virtual int left()
return this->getPositionX();


inline virtual int right()
return this->getPositionX() + _width;


inline virtual int top()
return this->getHeight();


inline virtual int bottom()
return 0;


;
#endif

#define TILE_H_SIZE 6
#define TILE_W_SIZE 8
#include "Block.h"
Block::~Block ()



Block::Block ()


Block * Block::create ()

Block * block = new Block();
if (block && block->initWithSpriteFrameName("blank.png"))
block->autorelease();
block->initBlock();
return block;

CC_SAFE_DELETE(block);
return NULL;

//设置街区:入参:宽,高,类型
void Block::setupBlock (int width, int height, int type)

this->setPositionY(_height);
switch (type)
case kBlockGap:
this->setVisible(false);
return;
case kBlock1:
break;
case kBlock2:
break;
case kBlock3:
break;
case kBlock4:
break;



1>Block.obj : error LNK2019: 无法解析的外部符号 "private: void __thiscall Block::initBlock(void)" (?initBlock@Block@@AAEXXZ),该符号在函数 "public: static class Block * __cdecl Block::create(void)" (?create@Block@@SAPAV1@XZ) 中被引用
1>C:\cocos2d-2.0-x-2.0.4\cocos2d-2.0-x-2.0.4\Debug.win32\paoku2.win32.exe : fatal error LNK1120: 1 个无法解析的外部命令
咋办啊

参考技术A initBlock函数没有实现

关于-->error LNK2019: 无法解析的外部符号

   首先,要了解这问题是怎么产生的,如此这般不在阐述,网上一搜一堆一堆。
         那遇到这情况,不要慌,不然掉头发。
         我们看到提示:“无法解析的外部符号”,我遇到的是用到了自定义函数,缺没有给函数下定义;导致跑不起来。
         想网上很多都阐述怎么怎么设置,然并卵,能码字的谁还会不懂设置,
         解决方案:在mian头给引用的函数下定义,即可。
         如:

//Max(int a, int b) 此处下定义
//{
// if (a > b)
// return a;
// else
// {
// return b;
// }
//}
int main()
{
int x = 10;
int y = 20;
int max = 0;
max = Max(x, y); 此处调用
printf("max=%d ", max);

return 0;

}

以上是关于高手救命·关于 error LNK2019: 无法解析的外部符号的主要内容,如果未能解决你的问题,请参考以下文章

error LNK2019: 无法解析的外部符

VC++编译错误提示-- error LNK2001: 无法解析的外部符号,望高手解决一下!

windows error LNK2019

error LNK2019: 无法解析的外部符号,麻烦帮忙看看这个错误是怎么回事?

error LNK2019: 无法解析的外部符号

error LNK2019: 无法解析的外部符号 WinMain,error LNK2001: 无法解析的外部符号 WinMain