LNK1123: 转换到 COFF 期间失败: 文件无效或损坏

连接器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。

导致这个错误的原因可能为:

在 Visual C++.NET 中,Microsoft 基础类 (MFC) 应用程序可以有多个资源 (.rc) 文件。但是,当您添加新的资源文件,其中包含一个字符串表,并再尝试生成项目或保存资源文件时,您会收到以下错误消息:

"资源数据是无效的。
无法保存资源脚本。
在新的资源文件的字符串表中添加新的字符串项,然后尝试重新生成该项目时可能会收到以下错误消息:
"致命的错误 CVT1100: 重复的资源。 类型: 字符串、 名称: 7、 语言: 0x0409"

"致命的错误 LNK1123: 转换到 COFF 期间失败: 文件无效或已损坏"
http://support.microsoft.com/kb/320216/zh-cn
这篇文章中的信息适用于:
  • Microsoft Visual C++ .NET 2002 标准版
  • Microsoft Visual C++ .NET 2003 Standard Edition

解决方案:将项目|项目属性|配置属性|连接器|清单文件|嵌入清单 “是”改为“否”


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.



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值