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

解决win32dll 使用MFC报 dllmain.obj 已定义

2013-12-31 15:55 218 查看
// 在WIN32DLL 中 使用MFC 会报错误 error LNK2005: _DllMain@12 已经在 dllmain.obj 中定义 nafxcw.lib RadiumCarved//是因为 把windows.h换成了afxwin.h后,有一个问题,afxwin.h中定义了一个Dllmain,而代码中又定义了一个Dllmain,所以链接时报错,Dllmain有重定义。

//新建一个.cpp文件 添加如下内容

//修改StdAfx.h文件:在#include <windows.h>前面加上#include <afx.h> ,加在后面就不行。并且这两个都要在stdafx.h的前面

#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: