1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Winodws10 VS Clion CMake 编译 OpenCV rc 系统找不到指定的文件。NMAKE : fatal error U1077

Winodws10 VS Clion CMake 编译 OpenCV rc 系统找不到指定的文件。NMAKE : fatal error U1077

时间:2018-07-18 15:30:43

相关推荐

Winodws10 VS Clion CMake 编译 OpenCV rc 系统找不到指定的文件。NMAKE : fatal error U1077

在从源码编译开源库这条路上,怎么这么多坑给我踩?

这次是编译OpenCV

简单总结

在 Windows10 系统下,使用 VS 编译链,在 Clion 编译 OpenCV 时,出现报错,报错的关键信息:

Detecting C compiler ABI info - failed

rc 系统找不到指定的文件。NMAKE : fatal error U1077

解决方案

指定 CMake 编译的目标平台/架构(platform/architecture),指定方式:

cmake -G "Visual Studio 16 " -A Win32cmake -G "Visual Studio 16 " -A x64cmake -G "Visual Studio 16 " -A ARMcmake -G "Visual Studio 16 " -A ARM64

痛苦回顾

来看看咱的报错信息

Microsoft Windows [版本 10.0.19043.1320](c) Microsoft Corporation。保留所有权利。C:\Workspace\CLion\opencv_next_test>cd buildC:\Workspace\CLion\opencv_next_test\build>"C:\Software\JetBrains\CLion .1.1\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEPENDS_USE_COMPILER=FALSE -G "CodeBlocks - NMake Makefiles" ../-- The C compiler identification is MSVC 19.29.30136.0-- The CXX compiler identification is MSVC 19.29.30136.0-- Detecting C compiler ABI info-- Detecting C compiler ABI info - failed-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio//Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio//Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - brokenCMake Error at C:/Software/JetBrains/CLion .1.1/bin/cmake/win/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):The C compiler"C:/Program Files (x86)/Microsoft Visual Studio//Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe"is not able to compile a simple test program.It fails with the following output:Change Dir: C:/Workspace/CLion/opencv_next_test/build/CMakeFiles/CMakeTmpRun Build Command(s):nmake -f Makefile /nologo cmTC_f9517\fast && "C:\Program Files (x86)\Microsoft Visual Studio\\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\nmake.exe" -f CMakeFiles\cmTC_f9517.dir\build.make /nologo -L CMakeFiles\cmTC_f9517.dir\buildBuilding C object CMakeFiles/cmTC_f9517.dir/testCCompiler.c.obj"C:\Software\JetBrains\CLion .1.1\bin\cmake\win\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_f9517.dir\testCCompiler.c.obj.d --working-dir=C:\Workspace\CLion\opencv_next_test\build\CMakeFiles\CMakeTmp --filter-prefix="" -- C:\PROGRA~2\MICROS~2\\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\cl.exe @C:\Users\ruan\AppData\Local\Temp\nm6CB6.tmpLinking C executable cmTC_f9517.exe"C:\Software\JetBrains\CLion .1.1\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_f9517.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\\COMMUN~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_f9517.dir\objects1.rsp @C:\Users\ruan\AppData\Local\Temp\nm6D92.tmpRC Pass 1: command "rc /fo CMakeFiles\cmTC_f9517.dir/manifest.res CMakeFiles\cmTC_f9517.dir/manifest.rc" failed (exit code 0) with the following output:系统找不到指定的文件。NMAKE : fatal error U1077: “"C:\Software\JetBrains\CLion .1.1\bin\cmake\win\bin\cmake.exe"”: 返回代码“0xffffffff”Stop.NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\nmake.exe"”: 返回代码“0x2”Stop.CMake will not be able to correctly generate this project.Call Stack (most recent call first):CMakeLists.txt:2 (project)-- Configuring incomplete, errors occurred!See also "C:/Workspace/CLion/opencv_next_test/build/CMakeFiles/CMakeOutput.log".See also "C:/Workspace/CLion/opencv_next_test/build/CMakeFiles/CMakeError.log".C:\Workspace\CLion\opencv_next_test\build>

关键是

Detecting C compiler ABI info - failed

rc 系统找不到指定的文件。NMAKE : fatal error U1077

根据jetbrains的说法,这不是他们的锅。

无论是在命令行还是在Clion里面都这样,但是好奇的是在Visual Studio 里面却没事?

然后,确实找不到rc

C:\Workspace\CLion\opencv_next_test\build>where rc.exe信息: 用提供的模式无法找到文件。

难道是VS里面有一些配置好的环境变量?

通过查找网上一堆rc和无法确定编译器的问题

Error: The C compiler is not able to compile a simple test program.

rc.exe no longer found in VS Command Prompt

Windows compilation error: Missing rc.exe

然鹅他们都不起作用,就算能找到rc,也会说找不到某些头文件。

停下来理一下思路,OpenCV编译失败,因为没有成功检测编译器的信息,原因是检测时找不到rc发生了中断。

那会不会是某些编译参数影响了呢?排查了一下,发现用下面这个参数编译就会出问题

cmake -G "CodeBlocks - NMake Makefiles" ../

好,VS用的应该是Visual Studio 16 ,那就改一下呗。

根据CMake的 文档,改成

cmake -G "Visual Studio 16 " ../

成功了~

补一张CLion设置CMake参数的图

CLion-->File-->Settings-->Build,Execution,Deployment-->CMake-->Release/Debug-->CMake options

添加

-G "Visual Studio 16 "

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。