ChatGPT解决这个技术问题 Extra ChatGPT

Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' after installing Visual Studio 2012 Release Preview

I've installed Visual Studio 2012 Release Preview, and it appears to be fine, but now when I try to use Visual Studio 2010 to compile C++ projects, I get the following error message:

LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

I'm not 100% sure of this, but it seems to be related to projects that have .rc (resource) files in them.

I've tried repairing Visual Studio 2010 from Add/Remove programs and rebooting, but this has no effect.

I also get the same error if I use Visual Studio 2012 RC to compile the C++ projects when set to use the Visual Studio 2010 toolset. Upgrading to the Visual Studio 2011 toolset fixes the problem (but of course I don't want to do this for production code).

Update: I've uninstalled Visual Studio 2012, rebooted, and the problem still persists! Help!

Is this an x86 issue, x64 issue, or both? I'm seeing it on a 32-bit operating system. I don't recall seeing it on a 64-bit operating system.

C
Callum Watkins

This MSDN thread explains how to fix it.

To summarize:

Either disable incremental linking, by going to Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"

or install VS2010 SP1.

Edits (@CraigRinger): Note that installing VS 2010 SP1 will remove the 64-bit compilers. You need to install the VS 2010 SP1 compiler pack to get them back.

This affects Microsoft Windows SDK 7.1 for Windows 7 and .NET 4.0 as well as Visual Studio 2010.


I ran into this problem soon after installing .Net 4.5. Installing VS2010 SP 1 resolved it. I did not install VS 2012 at any point.
To disable incremental linking with CMakefile: cmake.org/pipermail/cmake/2010-February/035174.html
In Qt under Visual Studio add to your .pro: QMAKE_LFLAGS += /INCREMENTAL:NO Worked for me
@grundic Sort of. We renamed cvtres.exe from the Win 7 sdk so that link.exe doesn't find it and instead uses the new one from .NET 4.5. The Windows 8 SDK no longer contains the command line tools. You now have to install at least Visual Studio 2012 Express for Desktops to get the desktop app command line tools. The rename solution was deemed the least disruptive, and can easily be scripted.
@DuckPuppy luckily, we solved this issue by completely removing Microsoft .Net 4.5.1 from our build agents and fresh install .Net 4.0. And after that we ran reinstall of Microsoft SDK 7.0 with all options marked - this solved our issues. Also, after this incident, we disabled autmatic updates - just in case.
M
Martin Ba

If disabling incremental linking doesn't work for you, and turning off "Embed Manifest" doesn't work either, then search your path for multiple versions of CVTRES.exe.

By debugging with the /VERBOSE linker option I found the linker was writing that error message when it tried to invoke cvtres and it failed.

It turned out that I had two versions of this utility in my path. One at C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cvtres.exe and one at C:\Windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe. 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.

(Really annoying that the error message has nothing to do with the actual problem, but that's not unusual for a Microsoft product.)

Just delete/rename the older version of the utility, or re-arrange your PATH variable, so that the version that works comes first.

Be aware that for x64 tooling builds you may also have to check C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 where there is another cvtres.exe.


Worked for me. Thanks for including the tip about /VERBOSE, which shows how/why instead of just what magic thing to do.
Just copy the newer file in the Framework directory over the old one in the visual studio directory.
This resolved my problem also. I'm working off of a computer that has strict UAC so I was able to confirm which cvtres.exe worked first from the command line. First ran where cvtres.exe. Then "C:\windows\Microsoft.NET\Framework\v4.0.30319.cvtres.exe /machine:amd64 /verbose /out:"Name from verbose output" /readonly FileFromVerboutput.res . One path showed an error, the .NET one worked.
In my case VS2012 is not installed, but .Net 4.0 and .Net 4.6 are installed and the error appears in VS2010. Renaming C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cvtres.exe solved the problem.
M
Michaelangel007

Check the version of cvtrs.exe:

dir "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe"

Wrong version:
date: 03/18/2010
time: 01:16 PM
size: 31,048 bytes
name: cvtres.exe

Correct version:
date: 02/21/2011
time: 06:03 PM
size: 31,056 bytes
name: cvtres.exe

If you have wrong version you should copy the correct version from:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cvtres.exe

and replace the one here:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe

i.e.

copy "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cvtres.exe" "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe"

This might help some other people with similar issues. I am using ms build and I had to Copy these files: msobj110.dll mspdb110.dll mspdbcore.dll mspdbsrv.exe From C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE to C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin in addition to this, as per i-am-bryan.com/webs/tutorials/…
This worked for me, but my "correct" cvtres.exe file was a different size, date, etc. (Still from VS 2012 bin, though)
For me solved by renaming cvtres from ....Studio 10.0\VC\bin\amd64\, directory. I think because I am using intel, not amd
m
mloskot

According to this thread in MSDN forums: VS2012 RC installation breaks VS2010 C++ projects, simply, take cvtres.exe from VS2010 SP1

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe

or from VS2012

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cvtres.exe

and copy it over the cvtres.exe in VS2010 RTM installation (the one without SP1)

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe

This way, you will effectively use the corrected version of cvtres.exe which is 11.0.51106.1.

Repeat the same steps for 64-bit version of the tool in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cvtres.exe.

This solution is an alternative to installation of SP1 for VS2010 - in some cases you simply can't install SP1 (i.e. if you need to support pre-SP1 builds).


That worked for me. Since I'm on win7 64-bit, I first copied cvtres.exe from the ...Framework64\v4.3... folder, but that didn't solve the problem. Then copied it from the Framework\v4.3... folder and that solved the problem THANK YOU!!!!!
r
rogerdpack

If you have installed Visual Studio 2012 RC, then it installed .NET 4.5 RC.

Uninstall .NET 4.5 RC, and install the version you need (4.0 for VS 2010). This should clear up any problems you are having.

This solved the same problem. There is no need to uninstall Visual Studio.


Great!! I only replaced .NET 4.5 with .NET 4.0. and it works fine!!
update: uninstalling .net 4.5 and 4.0 does fix it for me (VS 2010 express). however windows update seems to constantly upgrade back to .net 4.5.1 so I have to repeat this every so often. However, installing the "VS 2010 SP1" and voila, VS 2010 express now works too, with .Net 4.5.1 still installed.
P
Peter Mortensen

It's because of .NET Framework 4.5 is replacing .NET Framework 4.0. I uninstalled Visual Studio 2010 several times with no luck. When I removed .NET Framework 4.5 and reinstalled Visual Studio 2010 it went fine.

See Uninstall Visual Studio 11 completely to do a fresh install.


Confim it!!!!!!! Just reinstalling VC2010 does not help. After deletion of framework4.5 RC it's OK.
I installed umdh which installs .net 4.5 which broke visual studio 2010. after uninstalling .net 4.5 and reinstalling .net 4.0 my visual studio came back to life.
F
FractalSpace

For me, setting 'Generate Manifest' to 'No' fixed it. (Also fixed with /INCREMENTAL:NO)


R
Richard Peck

If you're using x64, here's a resource will help:

This happens because Microsoft .NET 4.5 is incompatible with Visual C++ 10. The workaround is to ensure that you run the .NET version of cvtres.exe rather than the Visual C++ version. I did this by renaming the Visual C++ versions of those files and copying the .NET versions in their place.

1. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe
2. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cvtres.exe

1. C:\windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe
2. C:\windows\Microsoft.NET\Framework64\v4.0.30319\cvtres.exe

note: this works because both .NET Framework 4 Multi-targeting pack and .NET Framework 4.5.2 are installed. The file C:\windows\Microsoft.NET\Framework\v4.0.30319\cvtres.exe belongs to .NET Framework 4 Multi-targeting pack. This will generally be the case if you have installed Windows SDK 7.1 and then later have .NET updated to 4.5.2. In this case, you can generally simply rename C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe to cvtres-old.exe and the newer cvtres.exe (dated 8/30/17) will be used and work fine.
O
Orion Edwards

I solved this problem eventually by doing a full uninstall of VS2012 RC, followed by a full uninstall of VS2010, then a reinstall from scratch of VS2010.

It took forever, but I'm now able to compile C++ projects in VS2010 again.


P
Peter Mortensen

The issue was magically resolved for me by removing .NET 4.5, and replacing it with .NET 4.0. I then had to repair Visual Studio 2010 - it being corrupted along the way somehow.

I had previously installed, and then un-installed, Visual Studio 2012 - which may be related to the issue.


This worked for me. I got the Net 4.5 as important Windows Update. I just uninstalled it, which made the build fail in a new way. Then I fully repaired the Visual Studio 2010 Express installation, and that fixed the issue.
P
Peter Mortensen

I have not installed Visual Studio 2012, but I still got this error in Visual Studio 2010. I got this resolved after installing Visual Studio 2010 SP1.


S
Sepideh Abadpour

I had the same problem with Microsoft Visual Studio 2010 Ultimate and it was solved by the method described in this youtube video

The video suggests to rename the file cvtres.exe in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin (in my Win7X64 matchine) to cvtres-old.exe


P
Peter Mortensen

It didn't work for me after Enable Incremental Linking -> "No (/INCREMENTAL:NO)", but it works for me after I deleted the rc file.


C
Community

+1 to user Short for an answer that worked for me!

I tried to do some debugging of this with msbuild /v:diag, and I'm seeing that MSBuild is trying to embed a manifest in the executable, with <somename>.dll.embed.manifest.res on the linker command line, where that is a resource file built from <somename>.dll.embed.manifest. But the manifest file is an empty Unicode text file. (That is, a two-byte file with the Unicode 0xFEFF prefix)

So the root problem seems to have something to do with that manifest file not being generated, or it being used when .dll.intermediate.manifest should have been used.

An alternate solution seems to be to turn off the "Embed Manifest" option under Properties, Manifest Tool, Input and Output.


H
Hung Pham

To summarize:

Step1

Project Properties 
   -> Configuration Properties 
       -> Linker (General) 
          -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"

if step1 not work, do Step2

Project Properties 
   -> Configuration Properties 
       -> Manifest Tool (Input and Output) 
          -> Enable Incremental Linking -> "No"

if step2 not work, do Step3 Copy file one of:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cvtres.exe C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cvtres.exe C:\Program Files (x86)\Microsoft Visual Studio 13.0\VC\bin\cvtres.exe Then, replace to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cvtres.exe With me, do 3 step it work


V
Vitality

As of January 2014, for some reasons I got installed .NET Framework 4.5.1, I don't know if due to a third party software installation or to an automatic update.

On January 29th, I got installed one component and I started receiving the

LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt 

message. At that time, I solved by avoiding the incremental link.

On Jan. 31st, I got installed another component of .NET Framework 4.5.1 and the incremental link trick did not work anymore. I then installed the Visual Studio 2010 SP1, but afterwards the problem became:

Error   6   error LNK1104: cannot open file 'msvcrtd.lib'. 

I think the SP1 messed up my Visual Studio 2010 installation.

So I uninstalled .NET Framework 4.5.1, installed .NET Framework 4.0 and uninstalled and then reinstalled Visual Studio 2010. That worked for me.


n
nerd

Even inspite of installing Service pack you are getting the error then try removing/renaming the cvtres.exe in the C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin folder. This has worked for me.


It worked for me. But I did not get how this was a problem. It would be appreciated if you can tell me. Thanks.
In the below answer, @Rich Peck has explained the reason for this behaviour.
s
sma6871

I set Enable Incremental Linking to "No (/INCREMENTAL:NO)" and it doesn't work for me.

Next I've changed:

Project Properties 
   -> Configuration Properties 
       -> General
          -> Platform Toolset -> "Visual Studio 2012 (v110)"

and it works for me :)


This won't work if you need to create an executable that is debuggable on a WinXP platform.
sorry but this is not a solution..you are changing toolset which is a completely different compiler
m
manimino

Reinstalling CMake worked for me. The new copy of CMake figured out that it should use Visual Studio 11 instead of 10.


V
Vijay Kumar Kanta

I was using the Windows SDK for core Win32 programming and had .NET 4.5 installed for "unknown" reasons. I have uninstalled that and installed 4.0 like previous answers and yeah, it worked for me too.

Just am flabbergasted that I had to use the useless .NET framework for building Win32 apps using the SDK.


P
Peter Mortensen

I solved this by doing the following:

In a command prompt, type msconfig and press enter. Click services tab. Look for "Application Experience" and put tick mark (that is, select this to enable). Click OK. And restart if necessary.

Thus the problem will go forever. Do build randomly and debug your C++ projects without any disturbance.


You can also enable Applicaton Experienc service from services.msc
What does this do for solving the problem?
P
Peter Mortensen

For those of you looking for a solution for this problem with the OpenGL SuperBible 6th source code samples, the solution is building in Release instead of Debug. All projects have disabled the incremental linking option in the Release version.


m
mihai

My problem was that I've had two paths on my PC that contained the same libraries. Both paths were added to the Additional Library Directories in Configuration Properties -> Linker -> General. Removing one of the paths solved the problem.


A
Aleksandr Khomenko

I had the same problem after updating of .NET: I uninstalled the .NET framework first, downloaded visual studio from visualstudio.com and selected "repair".

NET framework were installed automatically with visual studio -> and now it works fine!


h
hackjutsu

I tried a few times and finally solved the problem by uninstalling several times the VS2010. I think I hadn't uninstalled all the files and that's why it didn't work for the first time.

In the installation of VS2012, it is said that if you have VS2010 SP1 you can't work on the same project in both programs. It is recommended to have only one program.

Thanks!


A
Alexander Samoylov

I had this problem after I installed Visual Studio 2017 and .NET Framework 4.6 on the machine that previously had Visual Studio 2010.

The problem was that after such an installation the file msvcr100_clr0400.dll from C:\Windows\System32 was overwritten with the new one with a very small size ~19 Kb, however the former one was ~800 Kb.

After I restored the file manually from another build machine cvtres.exe started working properly again.