Ошибка lnk1123 в c visual studio 2010

Every time I try to build and debug the simple Hello World Code I get an error stating the following:

1>------ Build started: Project: helloworld, Configuration: Debug Win32 ------
1>  test.cpp
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

And im using this code:

#include <iostream>
using namespace std;
void main() {
cout << "Hello, World!" << endl;
}

and i think its whenever i use Main(), they tell me not to use it or something. help!!!

При работе с различными версиями Visual Studio и .Net Frameworks иногда возникают досадные неувязки. Далее о том, что делать, если линкер при сборке C++ проекта ругается следующим образом

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

 

Почему такое случается?

1)В

ы запускаете VS 2010 после установки VS 2012.
2) Был установлен новый .Net Framework 4.5
3) Файлы .Net Framework 4 не в порядке (повреждены или удалены)
4) Файлы VS 2010 не в порядке.

Как решить проблему для одного проекта?

Чтобы ваш проект линковал в не инкрементальном режиме можно установить в опциях проекта Linker->General->Incremental Linking значение NO. Это, конечно, имеет свои последствия, но зато обходит нашу текущую проблему.

Как решить проблему?

1,2) Для этих вариантов есть 2 пути решения

  • Удалить .Net Framework 4.5 и установить .Net Framework 4
  • Подменить файл cvtres.exe версии VS2010 версией VS2012 (Обычно они лежат C:Program Files (x86)Microsoft Visual Studio 10.0VCbincvtres.exe, C:Program Files (x86)Microsoft Visual Studio 11.0VCbincvtres.exe соответственно)

3,4) В остальных случаях просто переустановите соответствующие пакеты.

Удачного дэбага!

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!

Peter Mortensen's user avatar

При работе с различными версиями Visual Studio и .Net Frameworks иногда возникают досадные неувязки. Далее о том, что делать, если линкер при сборке C++ проекта ругается следующим образом

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

 

Почему такое случается?

1)В

ы запускаете VS 2010 после установки VS 2012.
2) Был установлен новый .Net Framework 4.5
3) Файлы .Net Framework 4 не в порядке (повреждены или удалены)
4) Файлы VS 2010 не в порядке.

Как решить проблему для одного проекта?

Чтобы ваш проект линковал в не инкрементальном режиме можно установить в опциях проекта Linker->General->Incremental Linking значение NO. Это, конечно, имеет свои последствия, но зато обходит нашу текущую проблему.

Как решить проблему?

1,2) Для этих вариантов есть 2 пути решения

  • Удалить .Net Framework 4.5 и установить .Net Framework 4
  • Подменить файл cvtres.exe версии VS2010 версией VS2012 (Обычно они лежат C:Program Files (x86)Microsoft Visual Studio 10.0VCbincvtres.exe, C:Program Files (x86)Microsoft Visual Studio 11.0VCbincvtres.exe соответственно)

3,4) В остальных случаях просто переустановите соответствующие пакеты.

Удачного дэбага!

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!

Peter Mortensen's user avatar

asked Jun 4, 2012 at 21:08

Orion Edwards's user avatar

Orion EdwardsOrion Edwards

121k63 gold badges236 silver badges328 bronze badges

1

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.

Callum Watkins's user avatar

answered Jun 5, 2012 at 1:19

Short's user avatar

15

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.0VCBINcvtres.exe and one at C:WindowsMicrosoft.NETFrameworkv4.0.30319cvtres.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.0VCbinamd64 where there is another cvtres.exe.

Martin Ba's user avatar

Martin Ba

36.8k33 gold badges180 silver badges335 bronze badges

answered Jan 3, 2013 at 18:14

Die in Sente's user avatar

Die in SenteDie in Sente

9,5063 gold badges35 silver badges41 bronze badges

4

Check the version of cvtrs.exe:

dir "C:Program Files (x86)Microsoft Visual Studio 10.0VCbincvtres.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.0VCbincvtres.exe

and replace the one here:

C:Program Files (x86)Microsoft Visual Studio 10.0VCbincvtres.exe

i.e.

copy "C:Program Files (x86)Microsoft Visual Studio 11.0VCbincvtres.exe" "C:Program Files (x86)Microsoft Visual Studio 10.0VCbincvtres.exe"

Michaelangel007's user avatar

answered Oct 9, 2013 at 11:04

Sid's user avatar

SidSid

4,8251 gold badge17 silver badges17 bronze badges

3

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.0VCbincvtres.exe

or from VS2012

C:Program Files (x86)Microsoft Visual Studio 11.0VCbincvtres.exe

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

C:Program Files (x86)Microsoft Visual Studio 10.0VCbincvtres.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.0VCbinamd64cvtres.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).

answered Mar 7, 2013 at 11:46

mloskot's user avatar

mloskotmloskot

36.7k11 gold badges107 silver badges134 bronze badges

1

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.

rogerdpack's user avatar

rogerdpack

62.1k36 gold badges267 silver badges386 bronze badges

answered Sep 4, 2012 at 22:51

B_Dubb42's user avatar

B_Dubb42B_Dubb42

5804 silver badges9 bronze badges

2

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

answered Sep 6, 2012 at 16:47

FractalSpace's user avatar

FractalSpaceFractalSpace

5,5373 gold badges42 silver badges47 bronze badges

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.0VCbincvtres.exe
2. C:Program Files (x86)Microsoft Visual Studio 10.0VCbinamd64cvtres.exe

1. C:windowsMicrosoft.NETFrameworkv4.0.30319cvtres.exe
2. C:windowsMicrosoft.NETFramework64v4.0.30319cvtres.exe

answered Mar 12, 2015 at 13:17

Richard Peck's user avatar

Richard PeckRichard Peck

75.9k9 gold badges93 silver badges145 bronze badges

1

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.

answered Jun 4, 2012 at 23:09

Orion Edwards's user avatar

Orion EdwardsOrion Edwards

121k63 gold badges236 silver badges328 bronze badges

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.

Peter Mortensen's user avatar

answered Oct 17, 2012 at 20:19

Caterpillar's user avatar

CaterpillarCaterpillar

5996 silver badges20 bronze badges

1

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.

Peter Mortensen's user avatar

answered Dec 5, 2012 at 14:38

Saji's user avatar

SajiSaji

1031 silver badge6 bronze badges

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.0VCbin (in my Win7X64 matchine) to cvtres-old.exe

answered May 14, 2016 at 11:21

Sepideh Abadpour's user avatar

Sepideh AbadpourSepideh Abadpour

2,53010 gold badges51 silver badges88 bronze badges

0

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

Peter Mortensen's user avatar

answered Mar 28, 2014 at 4:58

robin.lo's user avatar

robin.lorobin.lo

911 silver badge4 bronze badges

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

Community's user avatar

answered Oct 8, 2012 at 22:53

Die in Sente's user avatar

Die in SenteDie in Sente

9,5063 gold badges35 silver badges41 bronze badges

0

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.0VCbincvtres.exe
  2. C:Program Files (x86)Microsoft Visual Studio
    12.0VCbincvtres.exe
  3. C:Program Files (x86)Microsoft Visual Studio
    13.0VCbincvtres.exe

    Then, replace to C:Program Files (x86)Microsoft Visual Studio
    10.0VCbincvtres.exe
    With me, do 3 step it work

answered Sep 30, 2015 at 2:23

Hung Pham's user avatar

Hung PhamHung Pham

2052 silver badges3 bronze badges

0

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.

answered Feb 1, 2014 at 19:54

Vitality's user avatar

VitalityVitality

20.6k4 gold badges107 silver badges145 bronze badges

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.0VCbin folder. This has worked for me.

answered Nov 4, 2014 at 8:29

nerd's user avatar

nerdnerd

3391 gold badge5 silver badges16 bronze badges

2

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

answered Oct 11, 2012 at 6:06

sma6871's user avatar

sma6871sma6871

3,1883 gold badges38 silver badges52 bronze badges

2

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

answered Mar 26, 2013 at 20:38

manimino's user avatar

maniminomanimino

1,2451 gold badge11 silver badges11 bronze badges

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.

answered Jun 19, 2013 at 11:09

Vijay Kumar Kanta's user avatar

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.

Peter Mortensen's user avatar

answered Jun 12, 2013 at 10:57

App Work's user avatar

App WorkApp Work

21.8k5 gold badges25 silver badges38 bronze badges

2

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.

Peter Mortensen's user avatar

answered Aug 8, 2013 at 23:29

Gallo's user avatar

GalloGallo

516 bronze badges

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.

answered Oct 17, 2013 at 11:20

mihai's user avatar

mihaimihai

4,5443 gold badges29 silver badges42 bronze badges

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!

answered Jul 2, 2015 at 20:34

Alexander Khomenko's user avatar

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!

hackjutsu's user avatar

hackjutsu

8,22613 gold badges47 silver badges85 bronze badges

answered Jun 13, 2012 at 9:45

Vengage's user avatar

0

Студворк — интернет-сервис помощи студентам

Добрый день!

1-я попытка все встало,естественно!
Visual Studio 2010 Express,32-бит ноут,перерыла все,не могу понять,что не так?
библиотеку<cstdlib>включ,
про SPCK 1(но наверно он присутсв в этой trial с Microsoft?,я сегодня скачала),
про снос NET.Framework у меня 4.5 версия!

Какие могут быть решения?! Помогите пожалуйста)

C++
1
2
3
4
5
6
7
8
9
#include<iostream>
using namespace std;
 
int main()
{
cout <<"Hello, world!"<<endl;
system("pause");
return 0;
}

Выдает ошибку:1>—— Построение начато: проект: Brainstorm, Конфигурация: Debug Win32 ——
1> main.cpp
1>LINK : fatal error LNK1123: сбой при преобразовании в COFF: файл недопустим или поврежден
========== Построение: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========

RRS feed

  • Remove From My Forums
  • Question

  • I wish it would tell me what’s corrupt.

    any tips?

Answers

    • Edited by
      Elegentin Xie
      Monday, July 30, 2012 6:15 AM
    • Marked as answer by
      Elegentin Xie
      Thursday, August 2, 2012 4:44 AM

All replies

    • Edited by
      Elegentin Xie
      Monday, July 30, 2012 6:15 AM
    • Marked as answer by
      Elegentin Xie
      Thursday, August 2, 2012 4:44 AM
  • Same problem as above with the exception that I am install vs express 2010 and cant get past building anything.

    Background:

    I had downloaded vs 2012 express but wasnt successful cause i am using an old windows vista box (backup box). So i uninstalled 2012 express and installed vs 2010.

    Install was successful. Compilation fails at the end of building the library with the error:

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

    So far, I have uninstalled vs 2012 express, re-installed 2010 express and still the same error.

    Anyone have any ideas as to what to try next ??

    Sunil

  • Have you tried SP1? You can create a new thread…


    Reply, then visible.

  • Install was successful. Compilation fails at the end of building the library

    Are we to infer from this that you are trying to create a
    library rather than an exe? If so, what kind? DLL? Static?

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

    The typical cause is that you are passing a file to the linker
    which isn’t a valid obj file, static library, or import lib.

    If you are passing arguments to link which are source code,
    or object code created with an older or non-compatible
    compiler, you will get this error. Note that object code
    files are rarely portable across compilers or even some
    versions of the same compiler.

    Without details of what you are trying to do, and how,
    there is little we can suggest. Note that it is not
    likely an installation problem with VC++, but probably
    an issue with what you have in the project you are
    building.

    — Wayne

  • Thanks for taking the time for the answers !

    The problem is fixed now.

    Wayne: good explanation … I checked and i didnt have any obj files from my other system. I usually do a clean and obj files are in a different directory. Good point though.

    fyi: I was building a static library. It seems like there were a couple of issues.

    I removed vs 2012 express because of incompatibility with vista, and re-installed vs 2010 express. The problem still persisted.

    I removed all sql server 2012. Using windows, this was a lot of packages/programs.

    I reinstalled sql server 2012. Installed sql server 2010 then reinstalled vs 2010 express, and voila ! next build worked.

    Seems like there is a certain dependency and incompatibility between the two sql server versions and vs 2010 express ??

    I think the problem could have been avoided if vs 2012 express wouldnt have installed on vista in the first place, rather than failing at the end and not removing all installed components.

    Thanks again for all the answers,

    Sunil

  • Kaliber64,

       Found I had multiple versions of CVTRES.EXE on my system.

       VS2012 made my old 2010 cvtes.exe file obsolete in C:Program Files (x86)Microsoft Visual Studio 10.0VCbin

       I renamed the file with V2010 in front and .old extension. The version in   C:WindowsMicrosoft.NETFrameworkv4.0.30319    from 9/19/2012 was left in place and that fixed the error.

        I hope this helps.

    • Proposed as answer by
      ralf-Mumpi
      Saturday, February 22, 2014 9:22 PM
    • Unproposed as answer by
      ralf-Mumpi
      Saturday, February 22, 2014 9:23 PM
    • Proposed as answer by
      ramacpr
      Wednesday, November 30, 2016 5:16 AM

  • VS 2012 installation has changed all content from «C:Program Files (x86)Microsoft Visual Studio 10.0VCbin» to its RTMRel version (10.0.30319.1) while VS 2010 SP1 (10.0.40219.1) was installed (including cvtres.exe mentioned above).

    I changed back its content and problem has gone.

  • Thank you! this worked well.

  • This worked for me. Thanks a lot. 

  • THANK YOU!

    This was the quickest and easiest fix ever!

Понравилась статья? Поделить с друзьями:
  • Ошибка lnk1105 не удается закрыть файл
  • Ошибка lnk1104 не удается открыть файл msvcrtd lib
  • Ошибка lnk1104 не удается открыть файл msvcprtd lib
  • Ошибка lnk1104 не удается открыть файл msmpi lib
  • Ошибка lnk1104 не удается открыть файл kernel32 lib