LNK1169 和 LNK2005

错误重现:

1> vs2010创建 C++ win32 project, Application type: DLL.

2>为了在工程中使用 CString, 在 stdafx.h 中 Include <afx.h>.

3> 编译工程,编译结果如下:LNK1169 和 LNK2005

在网上找到一篇文章很详细的解释了这种现象的前因后果:

[随感]fatal error LNK1169: one or more multiply defined symbols found终极解决

下面是微软提供的一个解决方案:

Microsoft support: A LNK2005 error occurs when the CRT library and MFC libraries are linked in the wrong order in Visual C++

下面我就总结列出在vs2010中解决这些错误的具体操作:

方案1> Project property -> Configuration Properties -> Linker/General/Force File Output

选择 “Multiply Defined Symbol Only (/FORCE:MULTIPLE)”。

 

方案2> Project property -> Configuration Properties -> Linker/Command Line

将 /FORCE:MULTIPLE 加入到 Additional Options 里。

原文地址:https://www.cnblogs.com/cindy-hu-23/p/3719236.html