Monday, January 25, 2021

Error LNK1123 failure during conversion to COFF: file invalid or corrupt

Error LNK1123 failure during conversion to COFF: file invalid or corrupt issigraph C:\Demo_Temp\ISSIGraph_1.41r_win32_src (1)\issigraph\LINK

    Authoritive Fix from Microsoft

  1. Linker Tools Error LNK1123
  2. Input files must have the Common Object File Format (COFF) format. If an input file is not COFF, the linker automatically tries to convert 32-bit OMF objects to COFF, or runs CVTRES.EXE to convert resource files. This message indicates that the linker could not convert the file. This can also occur when using an incompatible version of CVTRES.EXE from another installation of Visual Studio, the Windows Development Kit, or .NET Framework.

    To fix the problem

    • Apply all service packs and updates for your version of Visual Studio. This is particularly important for Visual Studio 2010.
    • Try building with incremental linking disabled. On the menu bar, choose Project, Properties. In the Property Pages dialog box, expand Configuration Properties, Linker. Change the value of Enable Incremental Linking to No.
    • Verify that the version of CVTRES.EXE found first in your PATH environment variable matches the version of the build tools, or the version of the Platform Toolset, used by your project.
    • Try turning off the Embed Manifest option. On the menu bar, choose Project, Properties. In the Property Pages dialog box, expand Configuration Properties, Manifest Tool, Input and Output. Change the value of Embed Manifest to No.
    • Make sure that the file type is valid. For example, make sure that an OMF object is 32-bit and not 16-bit. For more information, see .Obj Files as Linker Input and PE Format.
    • Make sure that the file is not corrupt. Rebuild it, if necessary.

  3. C++ Tools and Features in Visual Studio Editions
  4. The following C++ features are available in Visual Studio 2019. Unless stated otherwise, all features are available in all editions: Visual Studio Community, Visual Studio Professional, and Visual Studio Enterprise. Some features require specific workloads or optional components, which you can install with the Visual Studio Installer.

    to be more specific, it is part of the C++ toolchain to turn resource files (.res) in to compiled objects that can be linked using the linker. – Scott Chamberlain Sep 4 '15 at 19:49

    My Fixes

  5. Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' after installing Visual Studio 2012 Release Preview
  6. A Solution Either disable incremental linking, by going to Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"

    A Solution 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.

    1. One at C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cvtres.exe and
    2. 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.

    A Solution To summarize:

    Step1 :

    Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)" if step1 not work, do Step2

    step 2:

    Project Properties -> Configuration Properties -> Manifest Tool (Input and Output) -> Enable Incremental Linking -> "No" if step2 not work, do Step3 Copy file one of:

    step 3:

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

  7. fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
  8. A SolutionI find out that I have the same problem. The problem is that my project setting is debug version, and the lib I include in the linker-->input is release version. After changing the project to release version, the problem disappear. After changing project to release version, you need to edit all the properties again.

  9. This is a paragraph.

  10. This is a paragraph.

  11. This is a paragraph.

  12. This is a paragraph.

  13. This is a paragraph.

  14. This is a paragraph.

  15. This is a paragraph.

  16. This is a paragraph.

  17. This is a paragraph.

  18. This is a paragraph.

  19. This is a paragraph.

  20. This is a paragraph.

  21. This is a paragraph.

  22. This is a paragraph.

No comments:

Post a Comment