链接器错误:错误LNK2019:未解析的外部符号
Linker error : error LNK2019: unresolved external symbol
我是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文件直接复制到项目文件夹中。我后来注意到它们没有显示在解决方案窗口中,并将它们复制到窗口中。之后,错误消失了。
相关文章:
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- spdlog标头仅与外部fmt一起使用.spdlog错误:'内部':不是'fmt'
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- Visual Studio 2017 中的 QtMetaObject 未解决的外部错误
- 外部"C"拆卸导致奇怪的链接器错误
- C++指针无法在函数外部传递值和分段错误(核心转储)错误
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 外部函数在 main() 上调用时返回分段错误 11.(C++)
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- 每次我要使用外部资源时,我都会得到:collect2。exe:错误 ld 返回 1 退出状态
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- C#WPF和C++/CLI以及C++在C++/CLI中添加外部库错误
- 函数 LNK2019 "int __cdecl __scrt_common_main_seh(void)" 中引用的未解析外部符号主错误 (?__scrt_common_main_seh@@YAHXZ
- C++:在"try"外部创建的类型会导致错误,但在内部不会
- 编译错误外部接口Simulink
- 为什么这会给出多个定义错误:外部 int i;国际 i;.