OpenCV:在Windows 7上构建库时cmake失败

时间:2014-07-22 03:53:55

标签: opencv cmake

系统信息:Windows 7,64位,Visual Studio 2010 Ultimate,CMake 3.0.0

我正在关注this tutorial从源代码构建opencv库。

问题出现在CMake阶段:

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

我已将C和C ++编译器的路径放在:

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

我注意到的另一件事是我的所有文件夹都是只读的,即使我在属性中手动取消选中它也是如此。 OpenCV源也是只读的。这可能是上述错误的原因吗?

2 个答案:

答案 0 :(得分:1)

对于那些不想恢复.Net 4的用户,请按以下步骤操作。

  • 重命名cvtres.exe $(YourVisualStudioInstallPath)\VC\bincvtres_old.exe

您最好在Win 7上使用OpenCV构建cmake + VisualStdio

推理cvtres.exe是一个可视化工作室实用程序,用于将资源文件转换为coff格式。您有两个版本,存在于您的计算机中。

  1. $(YourVisualStudioInstallPath)\VC\bin中的一个 - 版本 10.0
  2. C:\Windows\Microsoft.NET\Framework\v4.0.30319\中的第二位 - 版本 11.0
  3. 假设表示机器中最近的配置更改(如.Net 4.5安装),版本 10.0 已停止正常工作。因此,作为修复,我们只需重命名visual studio文件夹中的cvtres.exe,以便visual studio使用.Net4.0文件夹中较新的cvtres.exe(版本 11.0 )。 / p>

答案 1 :(得分:0)

首先,为什么必须手动指定编译器到CMake的路径?您是否安装了多个版本的Visual Studio?另外,您最近是否升级/更新了.NET框架?这可能是一个可能的原因。有关详细信息,请参阅下面的帖子。

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