您的位置:首页 > 大数据 > 人工智能

uafxcwd.lib(dllmodul.obj) : error LNK2005: DllMain 已经在 中定义

2010-09-19 23:17 483 查看
如果出现这种错误:“uafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12
already defined in main.obj ”或者“mfcs42ud.lib(dllmodul.obj) : error
LNK2005: _DllMain@12 already defined in main.obj ”,那么“See if you have
_AFXDLL and _USRDLL in the preprocessor definitions. Try removing one of
them”。具体位置:IDE中 菜单Project / Setting / C/C++ / preprocessor definition 。

Project / Setting / C/C++ / 代码生成---->>运行时库---->>多线程调试 DLL
(/MDd)

资深员工说加入以下代码:

#include "stdafx.h"

#ifdef _DEBUG

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

#define new DEBUG_NEW

/////////////////////////////////////////////////////////////////////////////

// global data

// The following symbol used to force inclusion of this module for
_USRDLL

#ifdef _X86_

extern "C" { int _afxForceUSRDLL; }

#else

extern "C" { int __afxForceUSRDLL; }

#endif

另外,极有可能是加了#include <afx.h>

后记:

来此取经的有人说:

http://hi.baidu.com/ollyestn/blog/item/c9baf4df832042e676c638a8.html

今天编译又碰到这个DllMain已经在xxx中被定义的问题,搜了一下,情况还很多,不过主要还是预定义的问题,我的预
定义宏如下:

_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_WINDOWS;_USRDLL;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE;

网上有人说是:“See if you have _AFXDLL and _USRDLL in the
preprocessor definitions. Try removing one of them”。但是我的定义里面只有一个 _USRDLL
而没有 _AFXDLL,但是在stdafx.h中代码中包括了包含了<afxwin.h>。

现在只要去掉_USRDLL ,再编译,OK。

简单的记下来,仅为下次碰到该问题时,不再迷惑。

----不知道是否真切
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐