用MinGW编译opencv时出错解决办法:(gcc 7.1.0 and cmake 3.9.0)->出错提示: windres.exe: unknown option -- W

环境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 [=<val>]    Define SYM when preprocessing rc file
  -U --undefine           Undefine SYM when preprocessing rc file
  -v --verbose                 Verbose - tells you what it's doing
  -c --codepage=     Specify default codepage
  -l --language=          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
  @                      Read options from 
  -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命令就可编译成功。

你可能感兴趣的:(用MinGW编译opencv时出错解决办法:(gcc 7.1.0 and cmake 3.9.0)->出错提示: windres.exe: unknown option -- W)