Win10下Qt+OpenCV+Cmake编译错误记录与解决【gcc: error: long: No such file or directory】
程序员文章站
2022-03-08 19:26:57
...
环境:Window10
Qt版本:5.9.5
OpenCV版本:4.3.0
安装完Opencv、Qt和Cmake之后在cmd下通过mingw32-make编译,结果出现错误,错误提示如下:
[ 39%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/mean.avx2.cpp.obj
[ 39%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/merge.avx2.cpp.obj
[ 40%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/split.avx2.cpp.obj
[ 40%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/sum.avx2.cpp.obj
[ 40%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
gcc: error: long: No such file or directory
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\windres.exe: preprocessing failed.
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1492: modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
mingw32-make[2]: *** Waiting for unfinished jobs....
mingw32-make[1]: *** [CMakeFiles\Makefile2:1844: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:179: all] Error 2
原因:the windres.exe mingw uses cannot handle/escape “long long” given as a cmdline arg
解决方法:在cmake里面找到OPENCV_ENABLE_ALLOCATOR_STATS或者在search里面搜索,然后把后面的勾选去掉,接着Configure和Generate后,接着在cmd窗口中mingw32-make即可继续编译。