LNK2005: _DllMain@12 already defined in LIBCMTD.lib(dllmain.obj)

今天使用VS2003创建一个MFC 的dll工程时,出现以下错误:

VPR error LNK2005: _DllMain@12 already defined in LIBCMTD.lib(dllmain.obj)
VPR error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpmtd.lib(newop.obj)
VPR error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
VPR error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj)
VPR error LNK2005: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj)
VPR warning LNK4006: _DllMain@12 already defined in LIBCMTD.lib(dllmain.obj); second definition ignored
VPR warning LNK4006: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in libcpmtd.lib(newop.obj); second definition ignored
VPR warning LNK4006: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj); second definition ignored
VPR warning LNK4006: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmtd.lib(newaop.obj); second definition ignored
VPR warning LNK4006: "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z) already defined in LIBCMTD.lib(delete2.obj); second definition ignored
VPR fatal error LNK1169: one or more multiply defined symbols found

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

因为刚开始时,我的工程是正常的,后面不懂我设置了神马地方,就出现以上错误了,

百度无果,想了下自己的操作,找到了错误的原因:

1.我在工程的属性中,禁止使用预编译头。

LNK2005: _DllMain@12 already defined in LIBCMTD.lib(dllmain.obj)_第1张图片


2.在XXX.cpp中,我去掉了#include "stdafx.h"  :

//#include "stdafx.h"

------------------------------------------------------------------------------------------------------------------------------------

知道了错误原因,解决就很简单了:

1.在工程属性中恢复使用预编译头。

2.在XXX.cpp中,写上如下代码:

#include "stdafx.h"









你可能感兴趣的:(LNK2005: _DllMain@12 already defined in LIBCMTD.lib(dllmain.obj))