0

System Info: Windows 7, 64 bit, Visual Studio 2010 Ultimate, CMake 3.0.0

I am following this tutorial to build opencv library from source.

The problem occurs at CMake stage:

The CXX compiler identification is MSVC 16.0.30319.1
The C compiler identification is MSVC 16.0.30319.1
Check for working CXX compiler using: Visual Studio 10 2010 Win64
Check for working CXX compiler using: Visual Studio 10 2010 Win64 -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.0/Modules/CMakeTestCXXCompiler.cmake:54 (message):
  The C++ compiler "c:/Program Files (x86)/Microsoft Visual Studio
  10.0/VC/bin/x86_amd64/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/Users/Hesh/Documents/opencv_built/CMakeFiles/CMakeTmp



  Run Build
  Command:"C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe"
  "cmTryCompileExec819411847.vcxproj" "/p:Configuration=Debug"
  "/p:VisualStudioVersion=10.0"

  Microsoft (R) Build Engine version 4.0.30319.17929


  [Microsoft .NET Framework, version 4.0.30319.17929]


  Copyright (C) Microsoft Corporation.  All rights reserved.





  Build started 7/22/2014 9:18:36 AM.


  Project
  "C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\cmTryCompileExec819411847.vcxproj"
  on node 1 (default targets).


  PrepareForBuild:


    Creating directory "cmTryCompileExec819411847.dir\Debug\".

    Creating directory "C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\Debug\".


  InitializeBuildStatus:


    Creating "cmTryCompileExec819411847.dir\Debug\cmTryCompileExec819411847.unsuccessfulbuild" because "AlwaysCreate" was specified.


  ClCompile:


    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\CL.exe /c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"cmTryCompileExec819411847.dir\Debug\\" /Fd"cmTryCompileExec819411847.dir\Debug\vc100.pdb" /Gd /TP /errorReport:queue testCXXCompiler.cxx

    Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64

    Copyright (C) Microsoft Corporation.  All rights reserved.



    cl /c /Zi /W3 /WX- /Od /Ob0 /D WIN32 /D _WINDOWS /D _DEBUG /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /Fo"cmTryCompileExec819411847.dir\Debug\\" /Fd"cmTryCompileExec819411847.dir\Debug\vc100.pdb" /Gd /TP /errorReport:queue testCXXCompiler.cxx



    testCXXCompiler.cxx


  ManifestResourceCompile:


    c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\rc.exe /nologo /fo"cmTryCompileExec819411847.dir\Debug\cmTryCompileExec819411847.exe.embed.manifest.res" cmTryCompileExec819411847.dir\Debug\cmTryCompileExec819411847_manifest.rc 


  Link:


    c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\Debug\cmTryCompileExec819411847.exe" /INCREMENTAL /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /ManifestFile:"cmTryCompileExec819411847.dir\Debug\cmTryCompileExec819411847.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:/Users/Hesh/Documents/opencv_built/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec819411847.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"C:/Users/Hesh/Documents/opencv_built/CMakeFiles/CMakeTmp/Debug/cmTryCompileExec819411847.lib" /MACHINE:X64 cmTryCompileExec819411847.dir\Debug\cmTryCompileExec819411847.exe.embed.manifest.res

    cmTryCompileExec819411847.dir\Debug\testCXXCompiler.obj  /machine:x64 /debug 


  LINK : fatal error LNK1123: failure during conversion to COFF: file invalid
  or corrupt
  [C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\cmTryCompileExec819411847.vcxproj]



  Done Building Project
  "C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\cmTryCompileExec819411847.vcxproj"
  (default targets) -- FAILED.





  Build FAILED.






  "C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\cmTryCompileExec819411847.vcxproj"
  (default target) (1) ->


  (Link target) -> 


    LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt [C:\Users\Hesh\Documents\opencv_built\CMakeFiles\CMakeTmp\cmTryCompileExec819411847.vcxproj]





      0 Warning(s)

      1 Error(s)





  Time Elapsed 00:00:00.85






  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:45 (project)


Configuring incomplete, errors occurred!
See also "C:/Users/Hesh/Documents/opencv_built/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Hesh/Documents/opencv_built/CMakeFiles/CMakeError.log".

I have put the path for compiler for C and C++ as:

C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/cl.exe 

Another thing I have noticed that all my folders are read-only, even if I manually un-check it in properties. The OpenCV source is also read-only. Could this be the reason for the above error ?

usr1234567
  • 21,601
  • 16
  • 108
  • 128
user2799508
  • 844
  • 1
  • 15
  • 41
  • Can you also show the output of CMake after you generated the Visual Studio project? To compile OpenCV you'll need some libraries and CMake will tell you if it can't find them. But your error, at least for now, appears to have nothing to do with missing libs. – lightalchemist Jul 22 '14 at 04:04

2 Answers2

1

For those who don't want to revert to .Net 4, please follow below step.

  • Rename cvtres.exe present in $(YourVisualStudioInstallPath)\VC\bin to cvtres_old.exe

And you are good to buildOpenCV with cmake + VisualStdio on Win 7.

Reasoning: cvtres.exe is a visual studio utility to convert resource files to coff formats. You have two versions of it, present in your machine.

  1. One in $(YourVisualStudioInstallPath)\VC\bin - Version 10.0
  2. Second in C:\Windows\Microsoft.NET\Framework\v4.0.30319\ - Version 11.0

I assume for a recent configuration change in your machine ( like .Net 4.5 install ), version 10.0 stopped working correctly. So as a fix, we just rename cvtres.exe present in visual studio folder so that visual studio uses the newer cvtres.exe ( version 11.0 ) present in .Net4.0 folder.

kiranpradeep
  • 10,859
  • 4
  • 50
  • 82
0

First, why did you have to manually specify the path of your compiler to CMake? Do you have multiple version of Visual Studio installed? Also, did you recently upgraded/updated your .NET framework? That could be a possible reason. See the posts below for more details.

http://delta3d.org/forum/viewtopic.php?showtopic=22426

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

Community
  • 1
  • 1
lightalchemist
  • 10,031
  • 4
  • 47
  • 55