静态链接编译通过,使用MFC共享dll编译不过

来源:百度知道 编辑:UC知道 时间:2024/05/15 14:08:30
在工程设置里面选择“使用MFC做为静态链接库”进行编译,一切正常
但是如果设置成“使用MFC做为共享dll”编译时就会出错,提示:'

D:\我的毕业设计\hchqq\DChatDlg.cpp(65) : warning C4273: 'protected: static struct AFX_MSGMAP const CDChatDlg::messageMap' : inconsistent dll linkage. dllexport assumed.
D:\我的毕业设计\hchqq\DChatDlg.cpp(65) : error C2491: 'CDChatDlg::messageMap' : definition of dllimport static data member not allowed

------错误提示附近代码-------------------------------------------------
void CDChatDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDChatDlg)
DDX_Control(pDX, IDC_STATIC_SYSTEM_INFO, m_static_info);
DDX_Control(pDX, IDC_CHECK_WANT_BACK, m_bnt_wantback);
DDX_Control(pDX, IDC_RICHEDIT_TEMP, m_temp_edit);
DDX_Control(pDX, IDC_STATIC_FACE, m_static_face);
DDX_Control(pDX, IDC_BUTTON_FACE, m_bnt_face);
DDX_Control(pDX, IDC_SEND_EDIT, m_send);
DDX_Control(pDX, IDC_RECI

你是用的那个版本的是VC6?还是2005?2008?

我遇到过2008有你的问题,是不是SDK冲突?去掉些包含目录试试

使用mfc是个很不好的习惯...

用basic也能写出很优秀的软件,你是从来没碰到过代码通用性的问题,想想你在网上找到的优秀代码段有几个是使用了mfc的,尽管BS我好了,有一天需要用BCB来编译你代码的时候哭死你

切,自己用不好就说是不好的习惯。
bs这种人,很多优秀的软件都是mfc写出来的。
CDChatDlg::messageMap
成员messageMap改成别的名字

#ifdef _AFXDLL
#define DECLARE_MESSAGE_MAP() \
private: \
static const AFX_MSGMAP_ENTRY _messageEntries[]; \
protected: \
static AFX_DATA const AFX_MSGMAP messageMap; \
static const AFX_MSGMAP* PASCAL _GetBaseMessageMap(); \
virtual const AFX_MSGMAP* GetMessageMap() const; \

#else
#define DECLARE_MESSAGE_MAP() \
private: \
static const AFX_MSGMAP_ENTRY _messageEntries[]; \
protected: \
static AFX_DATA const AFX_MSGMAP messageMap; \
virtual const AFX_MSGMAP* GetMessageMap() const; \

#endif

#ifdef _AFXDLL
#define BEGIN_MESSAGE_