请教DLL问题(详细说明)
在DLL里写了继承CView类,名为CmView类.在另一个EXE继承DLL里的CmView类
但总是报错(好象是DLL编写有问题)
************************DLL文件*************************
<<<<<<<<<<CmView.h>>>>>>>>>>
#pragma once
class AFX_EXT_CLASS CmView : public CView
{
DECLARE_DYNAMIC(CmView)
public:
__declspec(dllexport) CmView();
__declspec(dllexport) ~CmView();
};
<<<<<<<<<CmView.Cpp>>>>>>>>
#include "stdafx.h"
#include "CmView.h"
IMPLEMENT_DYNAMIC(CmView,CView)
CmView::CmView()
{
}
CmView::~CmView()
{
}
*****************************EXE文件**************************
<<<<<<<<<<<<InfoOrganizerView.h>>>>>>>>>>>>>
#pragma once
#include "CmView.h"
#pragma comment(lib,"dll.lib")
class CInfoOrganizerView : public CmView
{
protected:
CInfoOrganizerView();
DECLARE_DYNCREATE(CInfoOrganizerView)
public:
CInfoOrganizerDoc* GetDocument() const;
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
virtual ~CInfoOrganizerView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG
inline CInfoOrganizerDoc* CInfoOrganizerView::GetDocument() const
{ return reinterpret_cast<CInfoOrganizerDoc*>(m_pDocument); }
#endif
<<<<<<<<<<<<<<InfoOrganizerView.h>>>>>>>>>
#include "stdafx.h"
#include "InfoOrganizer.h"
#include "InfoOrganizerDoc.h"
#include "InfoOrganizerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
IMPLEMENT_DYNCREATE(CInfoOrganizerView, CmView)
BEGIN_MESSAGE_MAP(CInfoOrganizerView, CmView)
END_MESSAGE_MAP()
CInfoOrganizerView::CInfoOrganizerView()
{
}
CInfoOrganizerView::~CInfoOrganizerView()
{
}
BOOL CInfoOrganizerView::PreCreateWindow(CREATESTRUCT& cs)
{
return CmView::PreCreateWindow(cs);
}
void CInfoOrganizerView::OnDraw(CDC* /*pDC*/)
{
CInfoOrganizerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
}
#ifdef _DEBUG
void CInfoOrganizerView::AssertValid() const
{
CmView::AssertValid();
}
void CInfoOrganizerView::Dump(CDumpContext& dc) const
{
CmView::Dump(dc);
}
CInfoOrganizerDoc* CInfoOrganizerView::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CInfoOrganizerDoc)));
return (CInfoOrganizerDoc*)m_pDocument;
}
#endif //_DEBUG
报错如下:
InfoOrganizerView.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CmView::classCmView" (?classCmView@CmView@@2UCRuntimeClass@@B)
E:\备份程序库\Studio\InfoOrganizer\Debug\InfoOrganizer.exe : fatal error LNK1120: 1 unresolved externals