[visual-studio-2010] 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!

The answer is


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.


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


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

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.


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.


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.


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:

  1. C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cvtres.exe
  2. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cvtres.exe
  3. 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


I solved this by doing the following:

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

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


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.


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"

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.


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.


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 :)


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


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).


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.


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.


+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 <somename>.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.


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.


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!


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.


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.


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


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!


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


Examples related to visual-studio-2010

variable is not declared it may be inaccessible due to its protection level SSIS Excel Connection Manager failed to Connect to the Source This project references NuGet package(s) that are missing on this computer Gridview get Checkbox.Checked value error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj What is the difference between Visual Studio Express 2013 for Windows and Visual Studio Express 2013 for Windows Desktop? Attach (open) mdf file database with SQL Server Management Studio What is and how to fix System.TypeInitializationException error? Could not load file or assembly "Oracle.DataAccess" or one of its dependencies IIS error, Unable to start debugging on the webserver

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to visual-studio-2012

How to actually search all files in Visual Studio Tests not running in Test Explorer How to use _CRT_SECURE_NO_WARNINGS Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=11.0.0.0 How can I resolve the error: "The command [...] exited with code 1"? Could not load file or assembly Exception from HRESULT: 0x80131040 MSVCP120d.dll missing How can I change IIS Express port for a site The program can't start because MSVCR110.dll is missing from your computer Controlling execution order of unit tests in Visual Studio