環境Windows 7 x64
按照網上的教程安裝qt和opencv的過程中,對opencv-3.4.0源碼進行編譯時,出現如下錯誤
> make
[ 2%] Built target zlib
[ 5%] Built target libtiff
[ 8%] Built target libjpeg
[ 16%] Built target libwebp
[ 19%] Built target libjasper
[ 20%] Built target libpng
[ 25%] Built target IlmImf
[ 31%] Built target libprotobuf
[ 32%] Built target opencv_core_pch_dephelp
[ 32%] Built target pch_Generate_opencv_core
[ 32%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
v:\MinGW-Builds\mingw64\bin\windres.exe: unknown option -- W
Usage: v:\MinGW-Builds\mingw64\bin\windres.exe [option(s)] [input-file] [output-file]
The options are:
-i --input=<file> Name input file
-o --output=<file> Name output file
-J --input-format=<format> Specify input format
-O --output-format=<format> Specify output format
-F --target=<target> Specify COFF target
--preprocessor=<program> Program to use to preprocess rc file
--preprocessor-arg=<arg> Additional preprocessor argument
-I --include-dir=<dir> Include directory when preprocessing rc file
-D --define <sym>[=<val>] Define SYM when preprocessing rc file
-U --undefine <sym> Undefine SYM when preprocessing rc file
-v --verbose Verbose - tells you what it's doing
-c --codepage=<codepage> Specify default codepage
-l --language=<val> Set language when reading rc file
--use-temp-file Use a temporary file instead of popen to read
the preprocessor output
--no-use-temp-file Use popen (default)
-r Ignored for compatibility with rc
@<file> Read options from <file>
-h --help Print this help message
-V --version Print version information
FORMAT is one of rc, res, or coff, and is deduced from the file name
extension if not specified. A single file name is an input file.
No input-file is stdin, default rc. No output-file is stdout, default rc.
v:\MinGW-Builds\mingw64\bin\windres.exe: supported targets: pe-x86-64 pei-x86-64 pe-bigobj-x86-64 elf64-x86-64 elf64-l1om elf64-k1om pe-i386 pei-i386 elf32-i386 elf32-iamcu elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
modules/core/CMakeFiles/opencv_core.dir/build.make:1642: recipe for target `modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
CMakeFiles/Makefile2:1512: recipe for target `modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:162: recipe for target `all' failed
make: *** [all] Error 2
解決辦法:
1、本人蔘照的安裝教程:https://blog.csdn.net/sinat_36264666/article/details/73200739,在第二部分:配置cmake的第5步:選中“WITH_OPENGL”、“WITH_QT”,將“WITH_IPP”取消。然後再次點【Configure】中,同時將“ENABLE_PRECOMPILED_HEADERS”取消。
2、此時你根據教程配置到“第三部分:編譯OPENCV”的第一步:執行mingw32-make命令時,會出現如下錯誤:在文件opencv/sources/modules/videoio/src/cap_dshow.cpp中出錯 error : 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' was not declared in this scope ...。此時將cap_dshow.cpp文件打開,在#include "DShow.h"行的前面添加如下語句: #define NO_DSHOW_STRSAFE, before the line 。繼續執行mingw32-make命令就可編譯成功。