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

模板实例化函数链接出错:error LNK2019: unresolved external symbol,该如何处理

2012-02-23 
模板实例化函数链接出错:error LNK2019: unresolved external symbol共有12个类似的错误,我列出1个来。模板

模板实例化函数链接出错:error LNK2019: unresolved external symbol
共有12个类似的错误,我列出1个来。
模板:
template <class   T>
void   Blur(T*   SourceImage,   const   int   Width,   const   int   Height);

实例化:
template   void
Blur <unsigned   char>
(unsigned   char*,   const   int,   const   int);

但链接时出错:
Linking...
Image_demoDoc.obj   :   error   LNK2019:   unresolved   external   symbol   "void   __cdecl   Blur <unsigned   char> (unsigned   char   *,int,int) "   (??$Blur@E@@YAXPAEHH@Z)   referenced   in   function   "void   __cdecl   OnBlur(struct   HWND__   *) "   (?OnBlur@@YAXPAUHWND__@@@Z)
Release\Image_demo.exe   :   fatal   error   LNK1120:   11   unresolved   externals

在百度上搜了半天,有说模板声明和定义要放在一个文件中。我试过没用的。帮帮忙那!急!

[解决办法]
template void
Blur <unsigned char>
(unsigned char*, const int, const int);这个是模板特化 也需要实现的

模板在你调用的时候才会实例化的
例如char * p=0;
Blur(p ,32,43);在这个时候模板才会实例化

热点排行