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

25

539

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!

Sacculate answered 4/6, 2012 at 21:8 Comment(1)
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.Chastise
P
657

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.

Passing answered 5/6, 2012 at 1:19 Comment(15)
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.Mulligan
To disable incremental linking with CMakefile: cmake.org/pipermail/cmake/2010-February/035174.htmlHelaina
In Qt under Visual Studio add to your .pro: QMAKE_LFLAGS += /INCREMENTAL:NO Worked for meMercenary
I installed the SP1 available here, 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.Corny
What's the Windows SDK equivalent of "Install VS2010 SP1"? Upgrade to the newest Windows SDK? Our build process involves using the Windows SDK command line tools - none of the developers have Visual Studio installed except on a very few stations (we're a Java shop that has a few native DLLs that get built and the Windows SDK is all that's required). All of our developer machines have Windows SDK 7.1 installed, and some people have hit this problem.Hospitalization
@Hospitalization have you fixed your problem? We also have a bunch of build agents and all of them have only Windows SDK installed - I can't install VS2010 SP1.Cloudberry
@Cloudberry 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.Hospitalization
Look at that answer. Maybe this can solve your problem. https://mcmap.net/q/73580/-error-39-link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-invalid-or-corrupt-39-after-installing-visual-studio-2012-release-previewAnon
@Hospitalization 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.Cloudberry
As @Cloudberry mentioned, Just remove .Net 4.5 and install .Net 4.0 ! No more ErrorSpickandspan
neither of those 2 solutions cut if for me. the problem comes from .rc files and cvtres.exe tool which VS2010 version is broken, and one needs to use the one from .Net v4. exlanation here: stackoverflowmylove.blogspot.jp/2014/01/…Driftwood
Installing SP1 did not remove the 64 bit compilers for me. Maybe that issue is no more?Miry
this solved my problem but will it be ok to give even production builds with this incremental linking option disabled? Can it have any side-effects?Veradia
so in order to solve this issue I should go to disable incremental linking for every new project ?Protozoology
@MapX Thanks! To disable on CMake 3.13, I had to edit the CMake distribution files :( per eknori.de/2015-07-17/cmake-how-to-turn-off-incremental-linkingHindenburg
M
252

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.

Midkiff answered 3/1, 2013 at 18:14 Comment(4)
Worked for me. Thanks for including the tip about /VERBOSE, which shows how/why instead of just what magic thing to do.Greerson
Just copy the newer file in the Framework directory over the old one in the visual studio directory.Highpressure
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.Disband
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.Eastwood
I
50

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"
Iliad answered 9/10, 2013 at 11:4 Comment(3)
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/…Trousers
This worked for me, but my "correct" cvtres.exe file was a different size, date, etc. (Still from VS 2012 bin, though)Commodore
For me solved by renaming cvtres from ....Studio 10.0\VC\bin\amd64\, directory. I think because I am using intel, not amdSulphone
C
46

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

Cryptomeria answered 7/3, 2013 at 11:46 Comment(1)
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!!!!!Tver
W
36

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.

Wendeline answered 4/9, 2012 at 22:51 Comment(2)
Great!! I only replaced .NET 4.5 with .NET 4.0. and it works fine!!Gemmule
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.Repugn
F
15

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.

Felspar answered 18/6, 2012 at 17:14 Comment(2)
Confim it!!!!!!! Just reinstalling VC2010 does not help. After deletion of framework4.5 RC it's OK.Voncile
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.Comic
S
14

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

Seine answered 6/9, 2012 at 16:47 Comment(0)
F
14

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
Fusee answered 12/3, 2015 at 13:17 Comment(1)
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.Deianira
S
13

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.

Sacculate answered 4/6, 2012 at 23:9 Comment(0)
L
11

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.

Leann answered 17/10, 2012 at 20:19 Comment(1)
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.Demeanor
E
10

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.

Enthetic answered 5/12, 2012 at 14:38 Comment(0)
A
10

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

Ailurophobe answered 14/5, 2016 at 11:21 Comment(0)
D
7

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

Distill answered 28/3, 2014 at 4:58 Comment(0)
M
6

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

Midkiff answered 8/10, 2012 at 22:53 Comment(0)
C
5

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

Communism answered 30/9, 2015 at 2:23 Comment(0)
C
4

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.

Corny answered 1/2, 2014 at 19:54 Comment(0)
P
3

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.

Peery answered 4/11, 2014 at 8:29 Comment(2)
It worked for me. But I did not get how this was a problem. It would be appreciated if you can tell me. Thanks.Carlocarload
In the below answer, @Rich Peck has explained the reason for this behaviour.Peery
P
1

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!

Punitive answered 13/6, 2012 at 9:45 Comment(0)
C
1

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

Codee answered 11/10, 2012 at 6:6 Comment(2)
This won't work if you need to create an executable that is debuggable on a WinXP platform.Soonsooner
sorry but this is not a solution..you are changing toolset which is a completely different compilerFibered
S
1

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

Shaun answered 26/3, 2013 at 20:38 Comment(0)
R
1

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.

Rebus answered 12/6, 2013 at 10:57 Comment(2)
You can also enable Applicaton Experienc service from services.mscRebus
What does this do for solving the problem?Krahmer
C
1

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.

Constrictive answered 19/6, 2013 at 11:9 Comment(0)
A
1

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.

Aurelea answered 8/8, 2013 at 23:29 Comment(0)
D
1

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.

Desmoid answered 17/10, 2013 at 11:20 Comment(0)
E
1

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!

Evasion answered 2/7, 2015 at 20:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.