在vc2010里,引用其他的项目时,如果项目里只有一般的类,就没有问题,但是如果被引用的项目里有dialog对象(或者说有CDialog的子类)的话,就不行,会报错。
这个是什么原因导致的,要如何解决呢?
部分错误信息如下:
nafxcwd.lib(wincore.obj) : error LNK2005: "public: __thiscall CWnd::CWnd(void)" (??0CWnd@@QAE@XZ) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "private: __thiscall CWnd::CWnd(struct HWND__ *)" (??0CWnd@@AAE@PAUHWND__@@@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "int __stdcall _AfxModifyStyle(struct HWND__ *,int,unsigned long,unsigned long,unsigned int)" (?_AfxModifyStyle@@YGHPAUHWND__@@HKKI@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "public: static int __stdcall CWnd::ModifyStyle(struct HWND__ *,unsigned long,unsigned long,unsigned int)" (?ModifyStyle@CWnd@@SGHPAUHWND__@@KKI@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "public: static int __stdcall CWnd::ModifyStyleEx(struct HWND__ *,unsigned long,unsigned long,unsigned int)" (?ModifyStyleEx@CWnd@@SGHPAUHWND__@@KKI@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "void __stdcall _AfxPreInitDialog(class CWnd *,struct tagRECT *,unsigned long *)" (?_AfxPreInitDialog@@YGXPAVCWnd@@PAUtagRECT@@PAK@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "void __stdcall _AfxPostInitDialog(class CWnd *,struct tagRECT const &,unsigned long)" (?_AfxPostInitDialog@@YGXPAVCWnd@@ABUtagRECT@@K@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "void __stdcall _AfxHandleActivate(class CWnd *,unsigned int,class CWnd *)" (?_AfxHandleActivate@@YGXPAVCWnd@@I0@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "int __stdcall _AfxHandleSetCursor(class CWnd *,unsigned int,unsigned int)" (?_AfxHandleSetCursor@@YGHPAVCWnd@@II@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "long __stdcall AfxCallWndProc(class CWnd *,struct HWND__ *,unsigned int,unsigned int,long)" (?AfxCallWndProc@@YGJPAVCWnd@@PAUHWND__@@IIJ@Z) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "protected: static struct tagMSG const * __stdcall CWnd::GetCurrentMessage(void)" (?GetCurrentMessage@CWnd@@KGPBUtagMSG@@XZ) already defined in uafxcwd.lib(wincore.obj)
8>nafxcwd.lib(wincore.obj) : error LNK2005: "protected: long __thiscall CWnd::Default(void)" (?Default@CWnd@@IAEJXZ) already defined in uafxcwd.lib(wincore.obj)
------解决方案--------------------------------------------------------
你当前项目里是不是已经有一个和dialog相关的引用了?
从错误消息来看似乎是引用有冲突.....
------解决方案--------------------------------------------------------
引用?怎么操作的??
mfc 程序公用,一般三种方式,#include 源代码 ,编为dll ,做成lib
------解决方案--------------------------------------------------------
你是用
<Projectname> 属性页”对话框 ->“通用属性”->“框架和引用” ????
------解决方案--------------------------------------------------------
那个是针对托管程序的