如何在Windows上使用MinGW构建OpenCV 3.2.0 [英] How to build OpenCV 3.2.0 with MinGW on Windows

查看:632
本文介绍了如何在Windows上使用MinGW构建OpenCV 3.2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这篇文章包含了我(和其他用户)从源代码构建库时遇到的所有问题.由于没有教程,因此我决定创建此类FAQ帖子,以将所有解决方案组合在一起.希望对您有所帮助!

This post contains all the problems I (and other users) had while building the library from sources. As there is no tutorial, I decided to create this sort of FAQ post to put all the solutions together. Hope it will help!

配置:
OpenCV 3.2.0
MinGW-w64 x86_64-6.1.0-win32-seh-rt_v5-rev0

Configuration:
OpenCV 3.2.0
MinGW-w64 x86_64-6.1.0-win32-seh-rt_v5-rev0

我们欢迎您在答案中添加更多信息,因为将所有内容放在一个位置更方便.

You are welcome to add more information in the answers, as it is more handy to have everything in one place.

推荐答案

  1. 下载OpenCV并将其解压缩到您选择的文件夹中.
  2. opencv\sources现在包含CMakeLists.txt和所有其他必需文件.在CMake中配置项目. CLion用户可以只打开CMakeLists.txt.

  1. Download and unpack OpenCV to a folder of your choice.
  2. opencv\sources now contains CMakeLists.txt and all the other files necessary. Configure the project in CMake. CLion users may just open CMakeLists.txt.

  • 修复1 :sprintf ()家庭安全性错误.
    add_definitions(-DSTRSAFE_NO_DEPRECATE)添加到CMakeLists.txt的开头.这将为项目定义STRSAFE_NO_DEPRECATE符号并消除错误.
  • 修复2 :部分过多" as.exe错误.
    将以下行添加到CMakeLists.txt()的开头:

  • Fix 1: sprintf () family security error.
    Add add_definitions(-DSTRSAFE_NO_DEPRECATE) to the beginning of CMakeLists.txt. This will define STRSAFE_NO_DEPRECATE symbol for the project and suppress the error.
  • Fix 2: 'too many sections' as.exe error.
    Add the following lines to the beginning of CMakeLists.txt (source):

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wa,-mbig-obj")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-Wa,-mbig-obj")

  • 修复3 :最后一个参数必须是8位立即数".
    没有发现比对0x88而不是mask_lo = _MM_SHUFFLE(2, 0, 2, 0)(二进制10 00 10 00)和0xDD而不是mask_hi进行硬编码更好的了. 一旦我的问题得到更好的答案,我将更新此段.
  • 修复4 :MinGW中没有c ++ 11 thread.
    同样,这是一个肮脏的解决方案:在#endif // C++11之前在<mutex><thread><condition_variable>中添加#include <mingw.*.h>. ()
  • Fix 3: 'the last argument must be an 8-bit immediate'.
    Found nothing better than hardcoding 0x88 instead of mask_lo = _MM_SHUFFLE(2, 0, 2, 0) (binary 10 00 10 00) and 0xDD instead of mask_hi.
    As soon as my question gets a better answer, I will update this paragraph.
  • Fix 4: no c++11 threads in MinGW.
    Again, a dirty solution: added #include <mingw.*.h> to <mutex>, <thread>, <condition_variable> before #endif // C++11. (Source)
  • 这篇关于如何在Windows上使用MinGW构建OpenCV 3.2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆