链接器错误:错误LNK2019:未解析的外部符号

Linker error : error LNK2019: unresolved external symbol

本文关键字:错误 外部 符号 LNK2019 链接      更新时间:2023-10-16

我是C++新手,在运行我的应用程序时遇到了问题。我用谷歌搜索了这个问题,但由于大多数结果都是链接库,所以我开始了一个新线程。

我有一个类CRessizeableDialog,我从我的VtkDialogTest2对话框类继承了它。

VtkDialogTest2.h;

#pragma once
#include "CResizableDialog.h"

#ifdef _WIN32_WCE
#error "CDHtmlDialog is not supported for Windows CE."
#endif 
// VtkDialogTest2 dialog
class VtkDialogTest2 : public CResizableDialog
{
    DECLARE_DYNCREATE(VtkDialogTest2)
public:
    VtkDialogTest2(CWnd* pParent = NULL);   // standard constructor
    virtual ~VtkDialogTest2();
// Overrides
    HRESULT OnButtonOK(IHTMLElement *pElement);
    HRESULT OnButtonCancel(IHTMLElement *pElement);


// Dialog Data
    enum { IDD = IDD_DIALOG4 };
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    virtual BOOL OnInitDialog();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedOk();
};

VtkDialogTest2.cpp

#include "stdafx.h"
#include "Geometry.h"
#include "VtkDialogTest2.h"

IMPLEMENT_DYNCREATE(VtkDialogTest2, CResizableDialog)
VtkDialogTest2::VtkDialogTest2(CWnd* pParent /*=NULL*/)
    : CResizableDialog(VtkDialogTest2::IDD, pParent),
{
}
VtkDialogTest2::~VtkDialogTest2()
{
}
void VtkDialogTest2::DoDataExchange(CDataExchange* pDX)
{
    CResizableDialog::DoDataExchange(pDX);
}

BOOL VtkDialogTest2::OnInitDialog()
{
    CResizableDialog::OnInitDialog();
    //some code

    return TRUE;  // return TRUE  unless you set the focus to a control
}
BEGIN_MESSAGE_MAP(VtkDialogTest2, CResizableDialog)
    ON_BN_CLICKED(IDOK, &VtkDialogTest2::OnBnClickedOk)
END_MESSAGE_MAP()
//some code

我不知道我做错了什么。我从网上下载了一个示例,该示例以完全相同的方式使用 CResizableDialog.h 类,并将 CResizableDialog.h 和 CRessizeableDialog.cpp 复制到我的项目中。

我得到的错误是;

1>VtkDialogTest2.obj : error LNK2019: unresolved external symbol "public: __thiscall CResizableDialog::CResizableDialog(unsigned int,class CWnd *)" (??0CResizableDialog@@QAE@IPAVCWnd@@@Z) referenced in function "public: __thiscall VtkDialogTest2::VtkDialogTest2(class CWnd *)" (??0VtkDialogTest2@@QAE@PAVCWnd@@@Z)
1>VtkDialogTest2.obj : error LNK2019: unresolved external symbol "protected: virtual int __thiscall CResizableDialog::OnInitDialog(void)" (?OnInitDialog@CResizableDialog@@MAEHXZ) referenced in function "protected: virtual int __thiscall VtkDialogTest2::OnInitDialog(void)" (?OnInitDialog@VtkDialogTest2@@MAEHXZ)
1>VtkDialogTest2.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const * __stdcall CResizableDialog::GetThisMessageMap(void)" (?GetThisMessageMap@CResizableDialog@@KGPBUAFX_MSGMAP@@XZ)
1>C:UsersGeometry.exe : fatal error LNK1120: 3 unresolved externals

任何意见将不胜感激。

错误是因为我将CRessizeableDialog.h和CRessizeableDialog.cpp文件直接复制到项目文件夹中。我后来注意到它们没有显示在解决方案窗口中,并将它们复制到窗口中。之后,错误消失了。

相关文章: