写如下一个类
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>class CLoginEventSink : public IDispEventImpl< 0, CLoginEventSink, &(__uuidof(IFLoginEvents)), &(__uuidof(__FBase)), 1, 0 > 编译的时候出现如下错误:
LoginEventSink.obj : error LNK2001: unresolved external symbol "class ATL::CComModule _Module" (?_Module@@3VCComModule@ATL@@A)
Debug/UCDemo.exe : fatal error LNK1120: 1 unresolved externals 哪位知道是什么原因吗?
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>class CLoginEventSink : public IDispEventImpl< 0, CLoginEventSink, &(__uuidof(IFLoginEvents)), &(__uuidof(__FBase)), 1, 0 > 编译的时候出现如下错误:
LoginEventSink.obj : error LNK2001: unresolved external symbol "class ATL::CComModule _Module" (?_Module@@3VCComModule@ATL@@A)
Debug/UCDemo.exe : fatal error LNK1120: 1 unresolved externals 哪位知道是什么原因吗?
信息给完整点吧
PLCDB90.obj : error LNK2001: unresolved external symbol "class ATL::CComModule _Module" (?_Module@@3VCComModule@ATL@@A)
bin/PlcOperation.exe : fatal error LNK1120: 1 unresolved externals
解决:
添加ATL头文件
使用ATL前必须包含以下头文件:atlbase.h和atlcom.h,并且定义_Module变量[2]。把以下代码加到stdafx.h是最方便的:
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
在cpp文件中要对_Module进行定义。如下:
CcomModule _Module;
在添加了这两行之后,我们就可以使用ATL的功能了。而不必创建ATL的项目。
当然,如果项目是通过ATL项目向导产生的就不必再次添加头文件了。
http://www.jr163.org/cup2/18/18781.htm
http://www.cnblogs.com/furenjun/archive/2006/03/28/360834.html