简体   繁体   English

基于MFC对话框的项目中的VS2010链接器错误

[英]VS2010 Linker Error in MFC Dialog Based Project

I recently installed VS2010 Ultimate. 我最近安装了VS2010 Ultimate。 I'm trying to create a MFC dialog based program. 我正在尝试创建一个基于MFC对话框的程序。 I use the built in template, take all the default options, and then compile the project. 我使用内置模板,采用所有默认选项,然后编译项目。 I then get the following link errors. 然后,我得到以下链接错误。

1>------ Build started: Project: test1, Configuration: Debug Win32 ------
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall CWinApp::GetProfileIntW(wchar_t const *,wchar_t const *,int)" (?GetProfileIntW@CWinApp@@UAEIPB_W0H@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWinApp::WriteProfileInt(wchar_t const *,wchar_t const *,int)" (?WriteProfileInt@CWinApp@@UAEHPB_W0H@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > __thiscall CWinApp::GetProfileStringW(wchar_t const *,wchar_t const *,wchar_t const *)" (?GetProfileStringW@CWinApp@@UAE?AV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@PB_W00@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWinApp::WriteProfileStringW(wchar_t const *,wchar_t const *,wchar_t const *)" (?WriteProfileStringW@CWinApp@@UAEHPB_W00@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWinApp::GetProfileBinary(wchar_t const *,wchar_t const *,unsigned char * *,unsigned int *)" (?GetProfileBinary@CWinApp@@UAEHPB_W0PAPAEPAI@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWinApp::WriteProfileBinary(wchar_t const *,wchar_t const *,unsigned char *,unsigned int)" (?WriteProfileBinary@CWinApp@@UAEHPB_W0PAEI@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual class CDocument * __thiscall CWinApp::OpenDocumentFile(wchar_t const *,int)" (?OpenDocumentFile@CWinApp@@UAEPAVCDocument@@PB_WH@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CWinApp::RegisterWithRestartManager(wchar_t const *,unsigned long,unsigned long (__stdcall*)(void *),void *,unsigned long,unsigned long)" (?RegisterWithRestartManager@CWinApp@@UAEJPB_WKP6GKPAX@Z1KK@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual long __thiscall CWinApp::RegisterWithRestartManager(int,class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > const &)" (?RegisterWithRestartManager@CWinApp@@UAEJHABV?$CStringT@_WV?$StrTraitMFC@_WV?$ChTraitsCRT@_W@ATL@@@@@ATL@@@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual unsigned long __thiscall CWinApp::ApplicationRecoveryCallback(void *)" (?ApplicationRecoveryCallback@CWinApp@@UAEKPAX@Z)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual class CDataRecoveryHandler * __thiscall CWinApp::GetDataRecoveryHandler(void)" (?GetDataRecoveryHandler@CWinApp@@UAEPAVCDataRecoveryHandler@@XZ)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWinApp::IsTaskbarInteractionEnabled(void)" (?IsTaskbarInteractionEnabled@CWinApp@@UAEHXZ)
1>test1.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWinApp::RestartInstance(void)" (?RestartInstance@CWinApp@@UAEHXZ)
1>test1.obj : error LNK2019: unresolved external symbol "public: __thiscall CShellManager::CShellManager(void)" (??0CShellManager@@QAE@XZ) referenced in function "public: virtual int __thiscall Ctest1App::InitInstance(void)" (?InitInstance@Ctest1App@@UAEHXZ)
1>test1.obj : error LNK2019: unresolved external symbol "protected: virtual __thiscall CDialogImpl::~CDialogImpl(void)" (??1CDialogImpl@@MAE@XZ) referenced in function "public: virtual __thiscall CDialogEx::~CDialogEx(void)" (??1CDialogEx@@UAE@XZ)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual __thiscall CDialogImpl::~CDialogImpl(void)" (??1CDialogImpl@@MAE@XZ)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const * __stdcall CDialogEx::GetThisMessageMap(void)" (?GetThisMessageMap@CDialogEx@@KGPBUAFX_MSGMAP@@XZ)
1>test1Dlg.obj : error LNK2019: unresolved external symbol "public: __thiscall CDialogEx::CDialogEx(unsigned int,class CWnd *)" (??0CDialogEx@@QAE@IPAVCWnd@@@Z) referenced in function "public: __thiscall CAboutDlg::CAboutDlg(void)" (??0CAboutDlg@@QAE@XZ)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CDialogEx::GetRuntimeClass(void)const " (?GetRuntimeClass@CDialogEx@@UBEPAUCRuntimeClass@@XZ)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "public: virtual class CMenu * __thiscall CWnd::GetMenu(void)const " (?GetMenu@CWnd@@UBEPAVCMenu@@XZ)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CWnd::SetMenu(class CMenu *)" (?SetMenu@CWnd@@UAEHPAVCMenu@@@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CWnd::OnDrawIconicThumbnailOrLivePreview(class CDC &,class CRect,class CSize,int,int &)" (?OnDrawIconicThumbnailOrLivePreview@CWnd@@UAEXAAVCDC@@VCRect@@VCSize@@HAAH@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CDialogEx::OnCommand(unsigned int,long)" (?OnCommand@CDialogEx@@MAEHIJ@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CDialogEx::PreTranslateMessage(struct tagMSG *)" (?PreTranslateMessage@CDialogEx@@UAEHPAUtagMSG@@@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnTouchInputs(unsigned int,struct tagTOUCHINPUT *)" (?OnTouchInputs@CWnd@@MAEHIPAUtagTOUCHINPUT@@@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnTouchInput(class CPoint,int,int,struct tagTOUCHINPUT *)" (?OnTouchInput@CWnd@@MAEHVCPoint@@HHPAUtagTOUCHINPUT@@@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual unsigned long __thiscall CWnd::GetGestureStatus(class CPoint)" (?GetGestureStatus@CWnd@@MAEKVCPoint@@@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnGestureZoom(class CPoint,long)" (?OnGestureZoom@CWnd@@MAEHVCPoint@@J@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnGesturePan(class CPoint,class CPoint)" (?OnGesturePan@CWnd@@MAEHVCPoint@@0@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnGestureRotate(class CPoint,double)" (?OnGestureRotate@CWnd@@MAEHVCPoint@@N@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnGestureTwoFingerTap(class CPoint)" (?OnGestureTwoFingerTap@CWnd@@MAEHVCPoint@@@Z)
1>test1Dlg.obj : error LNK2001: unresolved external symbol "protected: virtual int __thiscall CWnd::OnGesturePressAndTap(class CPoint,long)" (?OnGesturePressAndTap@CWnd@@MAEHVCPoint@@J@Z)
1>test1Dlg.obj : error LNK2019: unresolved external symbol "public: long __thiscall CWnd::SendMessageW(unsigned int,unsigned int,long)const " (?SendMessageW@CWnd@@QBEJIIJ@Z) referenced in function "protected: void __thiscall Ctest1Dlg::OnPaint(void)" (?OnPaint@Ctest1Dlg@@IAEXXZ)
1>c:\Projects\test1\Debug\test1.exe : fatal error LNK1120: 32 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I've tried reinstalling VS2010 and made sure I had C++ installed, but I still get the errors. 我尝试重新安装VS2010,并确保已安装C ++,但仍然收到错误。 I've tried making the Multiple document and Single document types, these both work. 我尝试过制作多个文档和单个文档类型,这两个都可以。 So it's only the Dialog based one that has errors. 因此,只有基于对话框的对话框才会出错。

Thanks, John. 谢谢,约翰。

You have to link with MFC. 您必须与MFC链接。 Go to Project - > Project Property -> Configuration Properties -> In "Use of MFC" put "Use MFC in a Static Library" 转到项目->项目属性->配置属性->在“使用MFC”中,放入“在静态库中使用MFC”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM