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 模板中的链接错误
基础教程推荐
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
