MFC扩展DLL中的类继承问题,急求解决方案!急急急!

a_Doris 2008-10-31 12:46:47
在VC6.0中利用向导创建一个MFC AppWizard[dll]的MFC Extension Dll工程Test2,在工程Test2中添加继承CSpecialOperation(工程Test中)的类TestCtrl2,类的内容如下:
头文件:
#if !defined(AFX_TESTCTRL2_H__389D6F80_D547_49B9_99EF_E5F8C0AD2B61__INCLUDED_)
#define AFX_TESTCTRL2_H__389D6F80_D547_49B9_99EF_E5F8C0AD2B61__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// TestCtrl2.h : header file
//
#include "SpecialOperation.h"

/////////////////////////////////////////////////////////////////////////////
// CTestCtrl2 window

class CTestCtrl2 : public CSpecialOperation /*CSpecialOperation是属于工程Test的类*/
{
public:
CTestCtrl2();
public:
virtual ~CTestCtrl2();

protected:

DECLARE_MESSAGE_MAP()
};

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

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TESTCTRL2_H__389D6F80_D547_49B9_99EF_E5F8C0AD2B61__INCLUDED_)

源文件:
#include "stdafx.h"
#include "TestCtrl2.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTestCtrl2

CTestCtrl2::CTestCtrl2()
{
}

CTestCtrl2::~CTestCtrl2()
{
}

BEGIN_MESSAGE_MAP(CTestCtrl2, CSpecialOperation)
//{{AFX_MSG_MAP(CTestCtrl2)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

当Build工程Test2时出现链接错误,错误信息如下:
--------------------Configuration: Test2 - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
Test2.cpp
TestCtrl2.cpp
Generating Code...
Linking...
Creating library Debug/Test2.lib and object Debug/Test2.exp
TestCtrl2.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const
CSpecialOperation::messageMap" (?messageMap@CSpecialOperation@@1UAFX_MSGMAP@@B)
Debug/Test2.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

Test2.dll - 2 error(s), 0 warning(s)

请问如何解决这个链接错误?
...全文
158 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
taodm 2008-10-31
  • 打赏
  • 举报
回复
珍惜生命,远离扩展dll。
baihacker 2008-10-31
  • 打赏
  • 举报
回复
BEGIN_MESSAGE_MAP(CPortDlg, CDialog) //用你自己的
//{{AFX_MSG_MAP(CPortDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

楼主是少了这些东西了...
帅得不敢出门 2008-10-31
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 taodm 的回复:]
珍惜生命,远离扩展dll。
[/Quote]
何解?
a_Doris 2008-10-31
  • 打赏
  • 举报
回复
jia_xiaoxin:在CSpecialOperation类中已经声明了DECLARE_MESSAGE_MAP()
并且BEGIN_MESSAGE_MAP(CSpecialOperation,/*CSpecialOperation的基类*/) 中也已经声明了其基类!
这个在常规的DLL中能够Link成功,但是扩展DLL则不行
jia_xiaoxin 2008-10-31
  • 打赏
  • 举报
回复
在CSpecialOperation类中是否声明了DECLARE_MESSAGE_MAP()

但没有定义
BEGIN_MESSAGE_MAP(CSpecialOperation,/*CSpecialOperation的基类*/)
//{{AFX_MSG_MAP(CSpecialOperation)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

65,210

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧