Ошибка lnk1123 ошибка при преобразовании в coff

dkfl20001

3 / 3 / 1

Регистрация: 24.02.2010

Сообщений: 110

1

18.08.2012, 19:37. Показов 94794. Ответов 26

Метки нет (Все метки)


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

Всем привет! Начал программировать на c++, создал консольное приложение win32 и написал туда код:

C++
1
2
3
4
5
#include <iostream>
int main()
{
    std::cout << "Hello World" << std::endl;
}

Но при попытке компиляции пишет «сбой при преобразовании в COFF: файл недопустим или поврежден».
Visual Studio 2010 Ultimate…



0



2525 / 1751 / 152

Регистрация: 11.08.2012

Сообщений: 3,349

19.08.2012, 04:52

2

Вы используете win32 console или CLR? Если win32, то нехватает #include <windows.h>, и еще вы забыли return 0;( функция, не являющаяся процедурой (не void), должна возвращать значение того же типа, который указан перед ее названием, в вашем случае int)

Добавлено через 2 минуты
Кстати, не лучше ли прописать после #include using namespace std; чем каждый раз при использовании функций <iostream> указывать std::???



0



3 / 3 / 1

Регистрация: 24.02.2010

Сообщений: 110

19.08.2012, 13:33

 [ТС]

3

Я это не забыл, просто не написал, думал это очевидно, а проблему решил так:
удалил Net Framework 4.5, и переустановил visual c++ 2010. Теперь всё работает.



1



17 / 17 / 1

Регистрация: 15.12.2012

Сообщений: 9

08.04.2013, 21:02

4

Лучший ответ Сообщение было отмечено как решение

Решение

Лечится так:
Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> «No (/INCREMENTAL:NO)»



16



felix_julian

03.09.2013, 19:53

5

А как работает линковщик, если этот режим включен?

0 / 0 / 0

Регистрация: 09.10.2013

Сообщений: 2

09.10.2013, 11:39

6

Столкнулся с такой же проблемой. После переустановки 7 винды на более свежею sp1. Пробывал делать как советовали ниже, но ничего не помогало все равно выдавало LNK1123: сбой при преобразовании в COFF: файл недопустим или поврежден. Не знаю как у других, но у меня в пункте Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking был еще пункт <наследовать от родителя или от значений по умолчанию для проекта>. После того как я применил этот пункт все скомпилировалось на ура! И этот пункт в свойствах потом пропал и остались только два <YES/INCREMENTAL> и < /INCREMENTAL:NO>. Потом я выбрал < /INCREMENTAL:NO> как советовали выше



0



Неэпический

17815 / 10586 / 2044

Регистрация: 27.09.2012

Сообщений: 26,631

Записей в блоге: 1

10.10.2013, 03:08

7

Цитата
Сообщение от Twin_BY
Посмотреть сообщение

Пробывал делать как советовали ниже

а это?

Цитата
Сообщение от dkfl20001
Посмотреть сообщение

удалил Net Framework 4.5, и переустановил visual c++ 2010. Теперь всё работает.



0



0 / 0 / 0

Регистрация: 09.10.2013

Сообщений: 2

10.10.2013, 09:36

8

Пардон, ошибся) Надо было написать: — выше. Все перепробовал. Но заработало только когда выбрал <наследование от родителя …>



0



2 / 2 / 0

Регистрация: 17.01.2014

Сообщений: 6

19.01.2014, 18:53

9

Цитата
Сообщение от Snowacat
Посмотреть сообщение

Лечится так:
Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> «No (/INCREMENTAL:NO)»

А где находится «Project Properties»??



1



Неэпический

17815 / 10586 / 2044

Регистрация: 27.09.2012

Сообщений: 26,631

Записей в блоге: 1

19.01.2014, 19:16

10

Цитата
Сообщение от Coral
Посмотреть сообщение

А где находится «Project Properties»??

В меню.

Project Properties == Свойства проекта



0



2 / 2 / 0

Регистрация: 17.01.2014

Сообщений: 6

19.01.2014, 19:20

11

У меня просто всё на русском, кое-как нашел конечно.
Через 10 минут после того, как коммент написал



1



14 / 14 / 14

Регистрация: 05.10.2013

Сообщений: 141

25.03.2014, 00:39

12

Цитата
Сообщение от Snowacat
Посмотреть сообщение

Лечится так:
Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> «No (/INCREMENTAL:NO)»

Подскажите пожалуйста , где это будет в русской версии , а то я никак найти не могу.



0



545 / 378 / 56

Регистрация: 23.06.2013

Сообщений: 1,181

Записей в блоге: 6

25.03.2014, 05:53

13

Цитата
Сообщение от Dj Programmer
Посмотреть сообщение

Подскажите пожалуйста , где это будет в русской версии , а то я никак найти не могу.

Вкладка меню «Проект»/ Свойства: <проект>/Свойства конфигурации/Компоновщик/Включить инкрементную компоновку/»Нет (/INCREMENTAL:NO)»

Не по теме:

Вообще можно установить SP1 для Visual Studio 2010, тогда таких проблем не будет



4



-4 / 15 / 0

Регистрация: 07.07.2012

Сообщений: 91

11.07.2014, 10:40

14

Добрый день, знаю что вопрос решённый, но хочу предложить вариант который помог мне. А именно, я скачал и установил http://www.microsoft.com/ru-RU… x?id=23691 . (Без переустановки студии). Может кому пригодится



9



0 / 0 / 0

Регистрация: 31.08.2013

Сообщений: 38

14.02.2015, 14:42

15

Вкладка меню «Проект»/ Свойства: <проект>/Свойства конфигурации/Компоновщик/Включить инкрементную компоновку/»Нет (/INCREMENTAL:NO)»

а в визуал экспресс этой опции походу нету

Добавлено через 29 минут

спасибо, помогло.



0



0 / 0 / 1

Регистрация: 12.08.2013

Сообщений: 23

17.10.2015, 10:53

16

Отключение инкрементной компоновки не помголо. Помогло решение от Razor64)



0



0 / 0 / 0

Регистрация: 16.02.2016

Сообщений: 2

20.02.2016, 13:01

17

Спасибо большое Razor64! Ваше решение помогло



0



0 / 0 / 0

Регистрация: 16.03.2016

Сообщений: 1

16.03.2016, 21:08

18

Спасибо помогло…… ТОлько начинаю изучать С++…



0



0 / 0 / 0

Регистрация: 13.05.2016

Сообщений: 7

19.05.2016, 21:21

19

Спасибо! Помогло решение от Razor64



0



Строитель

458 / 75 / 4

Регистрация: 18.06.2010

Сообщений: 514

25.02.2017, 09:04

20

Цитата
Сообщение от Twin_BY
Посмотреть сообщение

Пардон, ошибся) Надо было написать: — выше. Все перепробовал. Но заработало только когда выбрал <наследование от родителя …>

Где находится?: наследование от родителя



0



При работе с различными версиями 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

After I have installed VS2012 my Qt project does not compiler anymore (have VS2010 and VS2012 on my computer). Message: LNK1123: failure during conversion to COFF: file invalid or corrupt . It was fine before with VS2010 only.

For the VS2012 environment it is recommended to (see SO here ):

  1. Compile with Enable Incremental Linking NO
  2. Uninstall .net 4.5

Since I am not using Qt in combination with VS2012 (so no plugIn), I cannot setup the project as mentioned. Nor can I uninstall .net 4.5 (needed for another project).

Is there any chance to solve the issue? Some related questions I have

  1. Would it be a solution to compile against VS2012 C++ compiler? Here it says I’d need an own compilation of Qt 5 for this — I would like to avoid such a hassle
  2. Do I need to update Qt?
  3. Or is there a way to simply set Incremental Linking to off as in a VS project? Where in the build settings (screenshot below) would I need to set it?

Win 7, x86
QtCreator 2.5.2
Qt 4.8.1
VS2012 Ultimate with Update 1, VS2010 still installed

Project compile settings

— Edit —

I crosschecked, the paths are still to VS2010 and there is no .net 4.5 path included.

Paths

— Edit 2 — as of HP’s comment

At least I have tried with my Anti Virus Software off. Same issue.
Furthermore I have checked some other smaller Qt projects (I am a sporadic Qt coder, so I do not have plenty of experience in that field). They do compile. Also all my sub projects in the affected Qt project do compile, only the last part (GUI, using all of the sub projects) fails with the above error.

— One step further —

In my .pro file I am using the following lines to get a DEFINE with the hg version, using this for ages.

VERSION = $$system(P:/Tools/TortoiseHg/hg parents --template '{latesttag}+{latesttagdistance}')
--- $$system line seems to be the line causing the COFF issue, WHY???
DEFINES += VERSION=\"$$VERSION\"

Taking this out, I was able to recompile without the COFF error. But the application crashed due to some mixed 4.8.0 / 4.8.1 libs. Then I went through all sub projects and found duplicated build configurations. Sometimes I had the same entries twice, sometimes missing. Corrected them, app runs now (still without the version tag).

Build configs

Checked the hg comment on CMD, seems to be OK.

>P:/Tools/TortoiseHg/hg parents --template '{latesttag}+{latesttagdistance}'
'0.8.902+1'

So why is this leading to the COFF error, and why the messed configurations?. Guess I am getting too old for this crap.

Я установил предварительный просмотр Visual Studio 2012 Release, и это выглядит нормально, но теперь, когда я пытаюсь использовать Visual Studio 2010 для компиляции проектов на С++, появляется следующее сообщение об ошибке:

LINK: фатальная ошибка LNK1123: сбой при преобразовании в COFF: файл недействителен или поврежден

Я не уверен на 100%, но, похоже, он связан с проектами, в которых есть .rc (resource) файлы.

Я попытался восстановить Visual Studio 2010 из «Установка и удаление программ» и перезагрузить, но это не имеет никакого эффекта.

Я также получаю ту же ошибку, если я использую Visual Studio 2012 RC для компиляции проектов на С++ при настройке на использование набора инструментов Visual Studio 2010. Обновление до набора инструментов Visual Studio 2011 устраняет проблему (но, конечно, я не хочу делать это для производственного кода).

Обновление: я удалил Visual Studio 2012, перезагрузился, и проблема по-прежнему сохраняется! Помогите!

Ответ 1

Этот поток MSDN объясняет, как его исправить.

Подводя итог:

  • Либо отключите инкрементную привязку, перейдя в

    Project Properties 
       -> Configuration Properties 
           -> Linker (General) 
              -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"
    
  • или установить VS2010 SP1.

Edits (@CraigRinger): Обратите внимание, что установка VS 2010 SP1 удалит 64-разрядные компиляторы. Вам нужно установить пакет компилятора VS 2010 SP1, чтобы вернуть их.

Это влияет на Microsoft Windows SDK 7.1 для Windows 7 и .NET 4.0, а также Visual Studio 2010.

Ответ 2

Если отключение инкрементной привязки не работает для вас, и выключение «Embed Manifest» тоже не работает, тогда найдите свой путь для нескольких версий CVTRES.exe.

Отладка с помощью опции linker/VERBOSE Я обнаружил, что компоновщик писал это сообщение об ошибке, когда пытался вызвать cvtres, и это не удалось.

Оказалось, что у меня есть два варианта этой утилиты на моем пути. Один в C:Program Files (x86)Microsoft Visual Studio 10.0VCBINcvtres.exe и один в C:WindowsMicrosoft.NETFrameworkv4.0.30319cvtres.exe. После установки VS2012 версия cvtres.exe VS2010 больше не будет работать. Если первый в вашем пути и компоновщик решает, что ему нужно преобразовать файл .res в формат объекта COFF, ссылка не будет работать с LNK1123.

(На самом деле раздражает, что сообщение об ошибке не имеет ничего общего с реальной проблемой, но это не является необычным для продукта Microsoft.)

Просто удалите/переименуйте устаревшую версию утилиты или переустановите свою переменную PATH, чтобы первая работала.

Помните, что для сборки инструментов x64 вам также необходимо будет проверить C:Program Files (x86)Microsoft Visual Studio 10.0VCbinamd64, где есть еще один cvtres.exe.

Ответ 3

Проверьте версию cvtrs.exe:

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

Неверная версия:
date: 03/18/2010
time: 13:16 вечера
size: 31 048 байт
name: cvtres.exe

Правильная версия:
date: 02/21/2011
time: 18:03

size: 31 056 байт
name: cvtres.exe

Если у вас неправильная версия, вы должны скопировать правильную версию из:

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

и замените его здесь:

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

то есть.

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

Ответ 4

В соответствии с этим вопросом на форумах MSDN: VS2012 RC-установка нарушает VS2010 проектов на С++, просто возьмите cvtres.exe из VS2010 SP1

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

или VS2012

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

и скопируйте его по cvtres.exe в установке VS2010 RTM (один без SP1)

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

Таким образом, вы эффективно используете исправленную версию cvtres.exe, которая является 11.0.51106.1.

Повторите те же шаги для 64-разрядной версии инструмента в C:Program Files (x86)Microsoft Visual Studio 10.0VCbinamd64cvtres.exe.

Это решение является альтернативой установке SP1 для VS2010 — в некоторых случаях вы просто не можете установить SP1 (т.е. если вам нужно поддерживать сборки до SP1).

Ответ 5

Если вы установили Visual Studio 2012 RC, то он установил .NET 4.5 RC.

Удалите .NET 4.5 RC и установите нужную версию (4.0 для VS 2010). Это должно устранить любые проблемы, с которыми вы сталкиваетесь.

Это решило ту же проблему. Нет необходимости удалять Visual Studio.

Ответ 6

Это из-за .NET Framework 4.5 заменяет .NET Framework 4.0.
Я удалил Visual Studio 2010 несколько раз без везения. Когда я удалил .NET Framework 4.5 и переустановил Visual Studio 2010, все прошло отлично.

Смотрите полностью удалить Visual Studio 11, чтобы выполнить новую установку.

Ответ 7

Для меня установка «Создать манифест» на «Нет» зафиксировала его. (Также исправлено с /INCREMENTAL: NO)

Ответ 8

В конечном итоге я решил эту проблему, выполнив полную удаление VS2012 RC, а затем полностью удалив VS2010, а затем переустановил с нуля VS2010.

Это потребовалось навсегда, но теперь я могу снова скомпилировать проекты на С++ в VS2010.

Ответ 9

Если вы используете x64, здесь ресурс поможет:

Это происходит потому, что Microsoft.NET 4.5 несовместим с Visual С++ 10. Обходной путь заключается в том, чтобы запустить версию cvtres.exe.NET, а не версию Visual С++. Я сделал это, переименовав версии этих файлов на Visual С++ и скопировав версии .NET на их место.

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

Ответ 10

Проблема была решена для меня, удалив .NET 4.5 и заменив ее .NET 4.0. Затем мне пришлось ремонтировать Visual Studio 2010 — это как-то повреждено.

Я ранее установил, а затем не установил Visual Studio 2012 — это может быть связано с проблемой.

Ответ 11

Я не установил Visual Studio 2012, но я все еще получил эту ошибку в Visual Studio 2010. Я получил это решение после установки Visual Studio 2010 SP1.

Ответ 12

+1 пользователю Short для ответа, который сработал у меня!

Я попытался выполнить некоторую отладку с помощью msbuild /v:diag, и я вижу, что MSBuild пытается внедрить манифест в исполняемом файле, с <somename> .dll.embed.manifest.res в командной строке компоновщика, где это файл ресурсов, построенный из <somename> .dll.embed.manifest. Но файл манифеста представляет собой пустой текстовый файл в Юникоде. (То есть двухбайтовый файл с префиксом Unicode 0xFEFF)

Таким образом, проблема с корнем, похоже, связана с тем, что файл манифеста не создается, или он используется, когда используется <somename> .dll.intermediate.manifest.

Альтернативное решение, похоже, заключается в отключении опции «Вставить манифест» в разделе «Свойства», «Инструмент манифеста», «Ввод и вывод».

Ответ 13

Это не сработало для меня после Enable Incremental Linking → «No (/INCREMENTAL: NO)», но он работает для меня после того, как я удалил файл rc.

Ответ 14

По состоянию на январь 2014 года по некоторым причинам я установил .NET Framework 4.5.1, я не знаю, связано ли это с установкой стороннего программного обеспечения или с автоматическим обновлением.

29 января я установил один компонент, и я начал получать

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

сообщение. В то время я решил, избегая инкрементной ссылки.

31 января я установил еще один компонент .NET Framework 4.5.1, и инкрементный трюк ссылки больше не работал. Затем я установил Visual Studio 2010 SP1, но потом проблема стала:

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

Я думаю, что SP1 испортил мою установку Visual Studio 2010.

Итак, я удалил .NET Framework 4.5.1, установил .NET Framework 4.0 и удалил, а затем переустановил Visual Studio 2010. Это сработало для меня.

Ответ 15

У меня была та же проблема с Microsoft Visual Studio 2010 Ultimate, и она была решена методом, описанным в это видео youtube

Видео предлагает переименовать файл cvtres.exe в C:Program Files (x86)Microsoft Visual Studio 10.0VCbin (in my Win7X64 matchine) до CVTRES-old.exe

Ответ 16

Даже несмотря на установку пакета обновления, вы получаете ошибку, затем попробуйте удалить/переименовать файл cvtres.exe в папке C:Program Files (x86)Microsoft Visual Studio 10.0VCbin. Это сработало для меня.

Ответ 17

Подводя итог:

Step1

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

Если step1 не работает, сделайте Step2

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

Если step2 не работает, сделайте Step3
Скопируйте файл один из:

  • C:Program Files (x86)Microsoft Visual Studio
    11,0VCBincvtres.exe
  • C:Program Files (x86)Microsoft Visual Studio
    12.0VCBincvtres.exe
  • C:Program Files (x86)Microsoft Visual Studio
    13,0VCBincvtres.exe

    Затем замените на C:Program Files (x86)Microsoft Visual Studio
    10,0VCBincvtres.exe
    Со мной, сделайте 3 шага, чтобы он работал.

Ответ 18

Я попробовал несколько раз и, наконец, решил проблему, удалив несколько раз VS2010. Я думаю, что я не удалил все файлы и почему он не работал в первый раз.

В установке VS2012 говорится, что если у вас есть VS2010 SP1, вы не можете работать над одним и тем же проектом в обеих программах. Рекомендуется иметь только одну программу.

Спасибо!

Ответ 19

Я установил Включить инкрементную привязку до «Нет (/INCREMENTAL: NO)» , и это не сработает для меня.

Далее я изменил:

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

и он работает для меня:)

Ответ 20

Моя проблема заключалась в том, что у меня было два пути на моем ПК, которые содержали те же библиотеки. Оба пути были добавлены в Дополнительные каталоги библиотек в Свойства конфигурации → Коннектор → Общие. Удаление одного из путей разрешило проблему.

Ответ 21

Переустановка CMake для меня. Новая копия CMake выяснила, что она должна использовать Visual Studio 11 вместо 10.

Ответ 22

Я решил это, выполнив следующее:

  • В командной строке введите msconfig и нажмите enter.
  • Нажмите вкладку служб.
  • Ищите «Application Experience» и поставьте галочку (т.е. выберите это для включения).
  • Нажмите «ОК». И при необходимости перезапустите.

Таким образом, проблема будет продолжаться вечно. Производите случайную работу и отлаживайте свои проекты на С++ без каких-либо помех.

Ответ 23

Я использовал Windows SDK для базового программирования Win32 и имел .NET 4.5 для «неизвестных» причин. Я удалил это и установил 4.0, как и предыдущие ответы, и да, это сработало и для меня.

Просто я ошеломлен тем, что мне пришлось использовать бесполезную платформу .NET для создания приложений Win32 с помощью SDK.

Ответ 24

Для тех из вас, кто ищет решение этой проблемы с помощью образцов OpenGL SuperBible 6-го исходного кода, решение создается в Release вместо Debug. Все проекты отключили инкрементную ссылку в версии Release.

Ответ 25

У меня была такая же проблема после обновления .NET:
Сначала я удалил .NET framework,
загрузили визуальную студию из visualstudio.com и выбрали «ремонт».

NET framework были установлены автоматически с визуальной студией → , и теперь она отлично работает!

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