Link Errors in Unmodified Visual Studio 2012 MFC Template when Statically Linking 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 模板中的链接错误


基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01