静态链接 MFC 时未修改的 Visual Studio 2012 MFC 模板中的链接错误

Link Errors in Unmodified Visual Studio 2012 MFC Template when Statically Linking MFC(静态链接 MFC 时未修改的 Visual Studio 2012 MFC 模板中的链接错误)

本文介绍了静态链接 MFC 时未修改的 Visual Studio 2012 MFC 模板中的链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2012 中创建最简单类型的新 MFC 应用程序并将其设置为静态链接到 MFC 时,链接失败.

When creating a new MFC application of the simplest kind in Visual Studio 2012, and setting it to link statically to MFC, linking fails.

这是从创建项目开始的7 个屏幕截图库通过向导,直到建筑物(导致链接器错误).中间没有进行源代码编辑.

错误日志状态:

1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>  stdafx.cpp
1>  TestDlg.cpp
1>  Test.cpp
1>  Generating Code...
1>uafxcwd.lib(afxctrlcontainer2.obj) : error LNK2005: "void __cdecl AfxRegisterMFCCtrlClasses(void)" (?AfxRegisterMFCCtrlClasses@@YAXXZ) already defined in afxnmcdd.lib(afxctrlcontainer2.obj)
1>uafxcwd.lib(afxctrlcontainer2.obj) : error LNK2005: "protected: void __thiscall CMFCControlContainer::PreUnsubclassControl(class CWnd *)" (?PreUnsubclassControl@CMFCControlContainer@@IAEXPAVCWnd@@@Z) already defined in afxnmcdd.lib(afxctrlcontainer2.obj)
1>uafxcwd.lib(afxctrlcontainer2.obj) : error LNK2005: "public: int __thiscall CMFCControlContainer::SubclassDlgControls(void)" (?SubclassDlgControls@CMFCControlContainer@@QAEHXZ) already defined in afxnmcdd.lib(afxctrlcontainer2.obj)
1>C:UsersXXXXXXXXDocumentsVisual Studio 2012ProjectsTestDebugTest.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

这只是我吗?您对如何解决这个问题有什么建议吗?

Is this just me? Would you have a suggestion on how to address this?

推荐答案

当我尝试将我的项目静态链接在一起时遇到了同样的问题.

I got the same problem when I try static link my project together.

正如 Michael Burr 所建议的,在 stdafx.h 中注释掉 #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS 行后似乎很好.

As Michael Burr suggested, it seems fine after commented out the line of #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS in stdafx.h.

这篇关于静态链接 MFC 时未修改的 Visual Studio 2012 MFC 模板中的链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:静态链接 MFC 时未修改的 Visual Studio 2012 MFC 模板中的链接错误

基础教程推荐