opencv - OpenCV:在Windows 7上构建库期间,cmake失败

标签 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源也是只读的。这可能是上述错误的原因吗?

最佳答案

首先,为什么必须手动指定编译器到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

关于opencv - OpenCV:在Windows 7上构建库期间,cmake失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24878610/

相关文章:

g++ - 如何使用 cmake 将编译器命令行参数放在特定位置

python - 如何使用 Python 和 OpenCV 实现良好的边缘检测来校准一些非常小的东西

java - opencv pyrDown() 对javacv 的相等方法是什么?

python - 调整引用另一个数组的numpy数组的大小

cmake - CMake将字符串解释为变量

cmake - 如何运行 CMakesetup?

python - OpenCV 尝试分割轮廓或在一个轮廓中找到两个最底部的点

python - opencv - 在图像中绘制轮廓

python - 从 CMake 在 Windows/Visual Studio 中以 Debug模式强制链接 Python 发布库

c++ - 如何显示cmake的gcc版本?