首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

CB2010中,在new vcl component时,出现“Unresolved external 'Extctrls:TTime,该怎么处理

2012-10-05 
CB2010中,在new vcl component时,出现“Unresolved external Extctrls::TTime如题,(新建一个元件时),求大

CB2010中,在new vcl component时,出现“Unresolved external 'Extctrls::TTime
如题,(新建一个元件时),求大侠帮手,是否写法出错还是少了什么头文件等?


/* Component1.h */
//---------------------------------------
#ifndef Component1H
#define Component1H
//---------------------------------------
#include <SysUtils.hpp>
#include <Classes.hpp>

#include <sysdyn.h>
#include <extctrls.hpp>

//---------------------------------------
class PACKAGE My : public TComponent
{
private:
protected:
public:
TTimer *CommTimer; /* 添加的一个 定时器指针 */

__fastcall My(TComponent* Owner);
__published:
};
//---------------------------------------
#endif


/* Component1.cpp */
//---------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Component1.h"
#pragma package(smart_init)

static inline void ValidCtrCheck(My *)
{
new My(NULL);
}
//---------------------------------------
__fastcall My::My(TComponent* Owner)
: TComponent(Owner)
{
  /* 如下3行 是添加的 */
  CommTimer= new TTimer(this); 
  CommTimer->Enabled=false;
CommTimer->Interval =10;
}
//---------------------------------------
namespace Component1
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(My)};
RegisterComponents(L"Samples", classes, 0);
}
}
//---------------------------------------



在选择Project->Builder All Projects 时,出现如下Error:
Checking project dependencies...
Building LeoPackage.cbproj (Debug configuration)
[ILINK32 Error] Error: Unresolved external 'Extctrls::TTimer::' referenced from C:\USERS\LEO\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\COMPONENT1.OBJ
[ILINK32 Error] Error: Unresolved external '__fastcall Extctrls::TTimer::TTimer(Classes::TComponent *)' referenced from C:\USERS\LEO\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\COMPONENT1.OBJ
[ILINK32 Error] Error: Unresolved external '__fastcall Extctrls::TTimer::SetEnabled(bool)' referenced from C:\USERS\LEO\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\COMPONENT1.OBJ
[ILINK32 Error] Error: Unresolved external '__fastcall Extctrls::TTimer::SetInterval(unsigned int)' referenced from C:\USERS\LEO\DOCUMENTS\RAD STUDIO\PROJECTS\DEBUG\COMPONENT1.OBJ
[ILINK32 Error] Error: Unable to perform link
Failed
Elapsed time: 00:00:00.5

[解决办法]
这个错误不是找不到TTimer的声明,而是TTimer的实现部分没有找到。

将$(BCB)\lib\bcbsmp.bpi添加到工程中即可。

$(BCB)是指你的C++Builder安装目录。

热点排行