CMake+mingw-w64编译opencv-3.3.1

1.打开CMake (cmake-gui),选择opencv-3.3.1源码路径和编译输出路径(如D:\build),依次点击Configure和Generating


2.若Configure时Downloading opencv_ffmpeg.dll失败,则应该手动下载该文件,打开\opencv-3.3.1\3rdparty\ffmpeg\ffmpeg.cmake文件,"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/"这一行中的变量用FFMPEG_FILE_HASH_BIN32或者FFMPEG_FILE_HASH_BIN64替换,再接上对应的文件名既可拼接出完整的文件路径,如:https://raw.githubusercontent.com/opencv/opencv_3rdparty/cf3bb5bc9d393b022ea7a42eb63e794d/ffmpeg/opencv_ffmpeg_64.dll。将下载下来的文件放到\opencv-3.3.1\3rdparty\ffmpeg\目录下,重新Configure即可成功

3. Configure和Generate成功后,到对应二进制输出目录运行mingw32-make即可开始编译opencv

4.若编译遇到下面问题:

D:\Program Files\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin\windres.exe: unknown option -- W
Usage: D:\Program Files\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin\windres.exe [option(s)] [input-file] [ou
tput-file]
 The options are:
  -i --input=            Name input file
  -o --output=           Name output file
  -J --input-format=   Specify input format
  -O --output-format=  Specify output format
  -F --target=         Specify COFF target
     --preprocessor=  Program to use to preprocess rc file
     --preprocessor-arg=  Additional preprocessor argument

则在cmake Configue的时候把ENABLE_PRECOMPILED_HEADERS这一项去掉

5. cd D:\build

mingw32-make && mingw32-make install
6. 将D:\build\install\x64\mingw\bin加入系统环境变量


你可能感兴趣的:(网络)