我有一个Visual Studio 6工作区我试图转换为Visual Studio 2008解决方案。该解决方案的输出是一个.dll。它必须是.dll,它需要静态链接MFC,因为我无法将MFC重新分配给现有客户。问题静态链接MFC库
该解决方案由三个项目组成,例如A,B,C。C是活动项目,输出.dll并依赖B. B输出.lib并依赖A. A输出.lib。
在常规配置属性中,我将A和B设置为静态库(.lib),将C设置为动态库(.dll)。所有三个项目都设置为“在静态库中使用MFC”。此外,所有三个项目都设置为运行时库的“多线程”,并且它们都没有定义_AFXDLL。
一切都建立正确直到最后连接阶段,我看到这一点:
1>nafxcw.lib(wincore.obj) : error LNK2005: _IsPlatformNT already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _InitMultipleMonitorStubs already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: [email protected] already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnGetSystemMetrics already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnMonitorFromWindow already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnMonitorFromRect already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnMonitorFromPoint already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnGetMonitorInfo already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnEnumDisplayMonitors already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_pfnEnumDisplayDevices already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_fMultiMonInitDone already defined in A.lib(Globals.obj)
1>nafxcw.lib(wincore.obj) : error LNK2005: _g_fMultimonPlatformNT already defined in A.lib(Globals.obj)
1>nafxcw.lib(viewprnt.obj) : error LNK2005: "public: virtual int __thiscall CPrintingDialog::OnInitDialog(void)" ([email protected]@@UAEHXZ) already defined in B.lib(ImagePropertiesDlg.obj)
1>nafxcw.lib(viewprnt.obj) : error LNK2005: "public: __thiscall CPrintingDialog::CPrintingDialog(class CWnd *)" ([email protected]@[email protected]@@@Z) already defined in B.lib(ImagePropertiesDlg.obj)
1>nafxcw.lib(viewprnt.obj) : error LNK2005: "public: virtual void __thiscall CPrintingDialog::OnCancel(void)" ([email protected]@@UAEXXZ) already defined in B.lib(ImagePropertiesDlg.obj)
我GOOGLE了这个问题死刑,并看到其他人有similarish的问题,但似乎无法来解决这个问题。我尝试将nafxcw.lib添加到C的忽略库中,但是这将这批链接器错误转换为1500多个未解决的符号错误。我可以把它编译/链接,如果我让它动态链接MFC,但正如我所说,我需要它静态链接。我觉得我错过了一些相当简单的事情,但似乎无法将其包围。任何和所有随机的想法和想法将不胜感激。
是的,我试过了。在这两个地方看起来绝对没有什么。 – Morinar 2009-11-18 20:42:32
你可以发布你使用的命令行编译器选项吗? – 2009-11-18 20:53:31
您是否忽略了错误消息中报告的*库*,然后在将它们添加回链接行时交换它们的顺序?并不是说我正在努力解决这个问题或任何问题,但这个答案并没有明确地表明这一点。过去我曾多次遭受过你的问题,而且“修复”一直对我有用。 – 2009-11-18 20:59:57