连接器LNK是通过调用cvtres.exe完成文件向coff格式的转换的,所以出现这种错误的原因就是cvtres.exe出现了问题。
在电脑里面搜索一下cvtres.exe,发现存在多个文件,使用最新的cvtres.exe替换老的文件即可,替换之前记得备份一下,如果不对,可以替换回来。
例如:我的电脑里面安装了vs2010,也安装了VS2012,After VS2012 install, the VS2010 version of cvtres.exe will no longer work. If that's the first one in your path, and the linker decides it needs to convert a .res file to COFF object format, the link will fail with LNK1123。
导致这个错误的原因可能为:
1 在 Visual C++.NET 中,Microsoft 基础类 (MFC) 应用程序可以有多个资源 (.rc) 文件。但是,当您添加新的资源文件,其中包含一个字符串表,并再尝试生成项目或保存资源文件时,您会收到以下错误消息:
解决方案:将项目|项目属性|配置属性|连接器|清单文件|嵌入清单 “是”改为“否”
2 VS212和VS2010同时安装了,此时VS2010会出现这种错误
解决方案有两种
一是升级VS2010为VS2010SP1
If Visual Studio 2012 RC and Visual Studio 2010 with SP1 are installed on the same computer, you can open the project in both of those versions of Visual Studio.
二是将旧的cvtres.exe替换为新的
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
C:\Windows\winsxs\x86_netfx-cvtres_for_vc_and_vb_b03f5f7f11d50a3a_6.1.7600.16385_none_ba476986f05abc65
C:\Windows\Microsoft.NET\Framework\v4.0.30319
这三个路径里面都有cvtres.exe文件,使用第二个路径里面的文件替换第一个路径的文件,问题解决。
..the x86 version of cvtres.exe had changed.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe
Wrong version: 03/18/2010 01:16 PM 31,048 cvtres.exe
Correct version: 02/21/2011 06:03 PM 31,056 cvtres.exe
The wrong version has a dependancy on msvcr100_clr0400.dll
The correct version has a dependancy on msvcr100.dll
Fortunately, I had another VS2010 installation without VS2012 installed on it where I found the GOOD version of cvtres.exe.
Once I copied the GOOD over the BAD everything builds sucessfully.
Quicker solution than uninstalling and re-installing but you have to have a good version of the file.