基于MFC对话框的VS2010链接错误。

时间:2022-04-16 07:26:56

I recently installed VS2010 Ultimate. I'm trying to create a MFC dialog based program. I use the built in template, take all the default options, and then compile the project. I then get the following link errors.

我最近安装了VS2010 Ultimate。我正在尝试创建一个基于MFC的对话程序。我使用内置模板,使用所有默认选项,然后编译项目。然后,我得到以下链接错误。

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. 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.

我尝试过重新安装VS2010,并确保安装了c++,但仍然会出现错误。我尝试过创建多个文档和单个文档类型,这些都是工作。这只是一个基于对话框的错误。

Thanks, John.

谢谢你,约翰。

1 个解决方案

#1


0  

You have to link with MFC. Go to Project - > Project Property -> Configuration Properties -> In "Use of MFC" put "Use MFC in a Static Library"

你必须和MFC联系。Go to Project ->项目属性->配置属性->在“使用MFC”put“在静态库中使用MFC”

#1


0  

You have to link with MFC. Go to Project - > Project Property -> Configuration Properties -> In "Use of MFC" put "Use MFC in a Static Library"

你必须和MFC联系。Go to Project ->项目属性->配置属性->在“使用MFC”put“在静态库中使用MFC”