error LNK2019: unresolved external symbol
2010-08-01 03:29
483 查看
error LNK2019: unresolved external symbol
(2007-05-28 10:23:43)![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
转载
分类: Programe(C/C++/VC/.NET) |
共有11个类似的错误,我列出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
折腾了4个小时,终于搞出来了。当然类似的错误百度搜索一大堆。我也查出原因了:模板声明和实现要放在同一文件夹中 ,我原先把声明放在了.h文件中,把实现放在了.cpp文件中。改了后运行还是出错。真是奇怪!我还以为是什么大的错误。后来重新启动了下VS2005就好了。原来我修改后,编译环境还以以前就的中间文件来编译,怪不得改了后还是没用。现在发现,有时候这VC环境还是有点“反应慢”。
其实,LNK2019错误一般都是 compile是能找到相应的header (.h)文件,但链接时找不到相应的 lib 库文件(也含dll文件)。如 昨天调试时再linux下 pointcloudviewerJ 项目能compile 和link 正确,但在 windows下设置了项目 属性 后 能compile 但link 时 报错如下:
1>Linking...
1>LINK : D:/Experiment_Data/Microsoft VC9/PointCloudViewerJ/Debug/PointCloudViewerJ.exe not found or not built by the last incremental link; performing full link
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall osgGA::StateSetManipulator::StateSetManipulator(class osg::StateSet *)" (__imp_??0StateSetManipulator@osgGA@@QAE@PAVStateSet@osg@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall osgGA::TrackballManipulator::TrackballManipulator(void)" (__imp_??0TrackballManipulator@osgGA@@QAE@XZ) referenced in function _main
。。。。。。。。
D:/Experiment_Data/Microsoft VC9/PointCloudViewerJ/Debug/PointCloudViewerJ.exe : fatal error LNK1120: 11 unresolved externals
这就是说一个link失败,使由于osgGA::StateSetManipulator::............的unresolved external symbol,也就是说 一定是osgGA库出了问题 。check 项目属性,发现 Additional Dependencies 中没有osgGA.lib , 所以 加上 osgGAd.lib(因为用的是Debug版)。rebuild 项目。compile 和link 通过。
另:有时候前面函数的声明 与 后面的 函数的定义 时的参数类型不同时,compile能通过,但link会出现LNK2019错误!
相关文章推荐
- error LNK2019: unresolved external symbol错误,解决
- [转]error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
- MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16
- error LNK2019: unresolved external symbol
- MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in funct
- MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in functi
- Qt 编译时出现“-1: error: LNK2019: unresolved external symbol "public: void __thiscall M”错误
- error LNK2019: unresolved external symbol
- error LNK2019: unresolved external symbol "__declspec(dllimport) void 遇到的问题以及解决办法
- 解决windows mobile下的编译错误error LNK2019: unresolved external symbol
- error LNK2019: unresolved external symbol "void __cdecl sqlcxt(void * *,unsigned int *,struct sqlexd
- mfc程序报错libcmt.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function
- error LNK2019: unresolved external symbol "public: class CVD::ImageRef __thiscall VideoSou
- WDM驱动开发 链接错误error LNK2019: unresolved external symbol @_RTC_CheckStackVars@8 referenced in function _main
- Qt中编译出现mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall MyWidget::M
- 转载:error LNK2019: unresolved external symbol __GSHandlerCheck referenced in function
- error LNK2019: unresolved external symbol __imp____lc_codepage referenced in function _mbrlen libmingwex.a
- opencv_highgui.lib(window_w32.obj) : error LNK2019: unresolved external symbol __imp__CreateToolbarE
- error LNK2019:unresolved external symbol *** referenced in function ***的解决方案
- vs2015编译gdal出错:error LNK2019: unresolved external symbol _vsnwprintf_s referenced in function String