如何在Windows上使用MinGW构建OpenCV 3.2.0 [英] How to build OpenCV 3.2.0 with MinGW on Windows
问题描述
这篇文章包含了我(和其他用户)从源代码构建库时遇到的所有问题.由于没有教程,因此我决定创建此类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.
推荐答案
- 下载OpenCV并将其解压缩到您选择的文件夹中.
-
opencv\sources
现在包含CMakeLists.txt
和所有其他必需文件.在CMake中配置项目. CLion用户可以只打开CMakeLists.txt
.
- Download and unpack OpenCV to a folder of your choice.
opencv\sources
now containsCMakeLists.txt
and all the other files necessary. Configure the project in CMake. CLion users may just openCMakeLists.txt
.
- 修复1 :
sprintf ()
家庭安全性错误.
将add_definitions(-DSTRSAFE_NO_DEPRECATE)
添加到CMakeLists.txt
的开头.这将为项目定义STRSAFE_NO_DEPRECATE
符号并消除错误. -
修复2 :部分过多"
as.exe
错误.
将以下行添加到CMakeLists.txt
(源)的开头:
- Fix 1:
sprintf ()
family security error.
Addadd_definitions(-DSTRSAFE_NO_DEPRECATE)
to the beginning ofCMakeLists.txt
. This will defineSTRSAFE_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 ofCMakeLists.txt
(source):
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wa,-mbig-obj")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-Wa,-mbig-obj")
没有发现比对
0x88
而不是mask_lo = _MM_SHUFFLE(2, 0, 2, 0)
(二进制10 00 10 00
)和0xDD
而不是mask_hi
进行硬编码更好的了.
一旦我的问题得到更好的答案,我将更新此段.thread
.同样,这是一个肮脏的解决方案:在
#endif // C++11
之前在<mutex>
,<thread>
,<condition_variable>
中添加#include <mingw.*.h>
. (源)
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.
thread
s 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屋!