OpenCV:cmake在windows 7上构建库时失败
系统信息:Windows 7,64位,Visual Studio 2010旗舰版,CMake 3.0.0 我下面是从源代码构建opencv库 问题发生在CMake阶段:OpenCV:cmake在windows 7上构建库时失败,opencv,cmake,Opencv,Cmake,系统信息:Windows 7,64位,Visual Studio 2010旗舰版,CMake 3.0.0 我下面是从源代码构建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 W
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 framework?这可能是一个原因。有关更多详细信息,请参阅下面的帖子
对于那些不想恢复到.Net 4的用户,请执行以下步骤
- 重命名中存在的cvtres.exe
至$(YourVisualStudioInstallPath)\VC\bin
cvtres\u old.exe
cmake+VisualStdio
构建OpenCV
推理:cvtres.exe
是一个visual studio实用程序,用于将资源文件转换为coff格式。您的计算机中有两个版本
$(YourVisualStudioInstallPath)\VC\bin
-版本10.0C:\Windows\Microsoft.NET\Framework\v4.0.30319\
-版本11.0I假设对于计算机中最近的配置更改(如.Net 4.5安装),版本10.0已停止正常工作。因此,作为修复,我们只需重命名visual studio文件夹中的
cvtres.exe
,以便visual studio使用.Net4.0文件夹中较新的cvtres.exe
(版本11.0)。生成visual studio项目后,是否也可以显示CMake的输出?要编译OpenCV,您需要一些库,如果找不到,CMake会告诉您。但您的错误,至少目前看来,似乎与缺少libs无关。@我删除了.NET framework 4.5并安装了4,它成功了,谢谢!!!