搭建OpenCV最新的4.6 + Qt5.12时,CMake GUI工具一直出错:
The CXX compiler identification is unknown
The C compiler identification is unknown
Check for working CXX compiler: */Qt/Tools/mingw730_64/bin/g++.exe
Check for working CXX compiler: */Qt/Tools/mingw730_64/bin/g++.exe -- broken
CMake Error at */Cmake/share/cmake-3.5/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "*/Qt/Tools/mingw730_64/bin/g++.exe" is not able
to compile a simple test program.
It fails with the following output:
Change Dir: */OpenCV/build/CMakeFiles/CMakeTmp
Run Build Command:"*/Qt/Tools/mingw730_64/bin/mingw32-make.exe"
"cmTC_c0a88/fast"
*/Qt/Tools/mingw730_64/bin/mingw32-make.exe -f
CMakeFiles\cmTC_c0a88.dir\build.make CMakeFiles/cmTC_c0a88.dir/build
mingw32-make.exe[1]: Entering directory
'*/OpenCV/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_c0a88.dir/testCXXCompiler.cxx.obj
*\Qt\Tools\mingw730_64\bin\g++.exe -o
CMakeFiles\cmTC_c0a88.dir\testCXXCompiler.cxx.obj -c
*\OpenCV\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_c0a88.dir\build.make:65:
CMakeFiles/cmTC_c0a88.dir/testCXXCompiler.cxx.obj] Error 1
mingw32-make.exe[1]: Leaving directory
'E:/GTFSoft/OpenCV/build/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:125: cmTC_c0a88/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:111 (enable_language)
Configuring incomplete, errors occurred!
See also "*/OpenCV/build/CMakeFiles/CMakeOutput.log".
See also "*/OpenCV/build/CMakeFiles/CMakeError.log".
看起来很明显嘛,找不到C/CXX compiler~
但实际上,第一次configure的时候是指定过的,通过GUI上的环境变量查看也是正常的,所以造成困惑:为什么找不到??
检查windows环境变量,通过cmd查看默认的gcc -v,发现是VS的,于是删掉先,只留Qt MinGW的在里面,然后重试,还是错误,但这也是一种错误情况。
然后,试过更换Cmake OpenCV的版本重试,当然这应该是比较蠢的,只是没办法了的测试。当然还是不行。
接着想起了被忽略的一项:直接从命令行执行。
通过命令行执行CMake …是成功的,那这只能说明一个问题了,CMake-gui用的环境和cmd里是不一样的,也就是gui里的环境没被刷新。
百度,尝试不重启刷新,无论是网友说的什么答案,都只是在cmd及时生效,在CMake-gui即使点开env按钮看到变化了,执行时还是没刷新。
没办法了,只好使用重启大法,然后一切正常。
:注重方法,推理,而不是完全相信网络上的东西。