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

// 在WIN32DLL 中 使用MFC 会报错误   error LNK2005: _DllMain@12 已经在 dllmain.obj 中定义    nafxcw.lib    RadiumCarved

//是由于 把windows.h换成了afxwin.h后,有一个问题,afxwin.h中定义了一个Dllmain,而代码中又定义了一个Dllmain,因此连接时报错,Dllmain有重定义。windows

 

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

//修改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
io

相关文章
相关标签/搜索