win10 + Qt5.14.0(mingw73_64) 下的 OpenCV4.5.1源码编译 注意事项

1 篇文章 0 订阅

大体的流程 别的博客上有,大体比较类似。这里不进行详细的介绍。

CMake 的版本 不能过高,例如3.19.x   之类的,我这里用的是3.10.x,否则会莫名其妙的失败。(用了最新的CMake导致的编译失败 就浪费了我一天的时间,还真的什么都不能用最新的)

勾选 WITH_QT
勾选 WITH_OPENGL
不勾选 OPENCV_ENABLE_ALLOCATOR_STATS  BUILD_opencv_world
CMAKE_BUILD_TYPE 选择 Release或Debug

勾选OPENCV_ENABLE_NON_FREE选项。【专利算法模块,包含特征检测和GPU相关的内容】

手动   添加环境     OPENCV_VS_VERSIONINFO_SKIP    bool     打勾

CMAKE_MAKE_PROGRAM    D:/Qt/Qt5.14.0/Tools/mingw730_64/bin/mingw32-make.exe

如果 安装了  Anaconda3  ,CMake configure的时候 会搜索到  python 之类的环境 ,然后会自动帮你  配置好,但是  我不想要python  啊。

解决方法: 先   删除Anaconda3  放入回收站 ,安装完 后再恢复。  搜索 python  把  有关的python 的  选项  都  不 选。

若使用opencv_contrib模块,记得 不勾选   BUILD_opencv_xfeatures2d   (这个会从国外下载一堆的模块之类的,但 国内防火墙....大家懂的)

OPENCV_EXTRA_MODULES_PATH:  若使用opencv_contrib模块,则在此处填写解压后的路径,如 D:\opencv_contrib\modules\

----------------------------------------------------下面是 我的   OpenCV4.5.1 配置------------------------------------------

Detected processor: AMD64

Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7")

Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")

AVX_512F is not supported by C++ compiler

AVX512_COMMON is not supported by C++ compiler

AVX512_SKX is not supported by C++ compiler

Dispatch optimization AVX512_SKX is not available, skipped

libjpeg-turbo: VERSION = 2.0.6, BUILD = opencv-4.5.1-libjpeg-turbo

Could NOT find OpenJPEG (minimal suitable version: 2.0, recommended version >= 2.3.1). OpenJPEG will be built from sources

OpenJPEG: VERSION = 2.3.1, BUILD = opencv-4.5.1-openjp2-2.3.1

OpenJPEG libraries will be built from sources: libopenjp2 (version "2.3.1")

Could not find OpenBLAS include. Turning OpenBLAS_FOUND off

Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off

A library with BLAS API not found. Please specify library location.

LAPACK requires BLAS

A library with LAPACK API not found. Please specify library location.

Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)

VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file

OpenCV Python: during development append to PYTHONPATH: D:/opencv/build4/python_loader

Module opencv_alphamat disabled because the following dependencies are not found: Eigen

Caffe: NO

Protobuf: NO

Glog: NO

freetype2: NO

harfbuzz: NO

Julia not found. Not compiling Julia Bindings.

Module opencv_ovis disabled because OGRE3D was not found

No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.

Failed to find installed gflags CMake configuration, searching for gflags build directories exported with CMake.

Failed to find gflags - Failed to find an installed/exported CMake configuration for gflags, will perform search for installed gflags components.

Failed to find gflags - Could not find gflags include directory, set GFLAGS_INCLUDE_DIR to directory containing gflags/gflags.h

Failed to find glog - Could not find glog include directory, set GLOG_INCLUDE_DIR to directory containing glog/logging.h

Module opencv_sfm disabled because the following dependencies are not found: Eigen Glog/Gflags

Tesseract: NO

Excluding from source files list: <BUILD>/modules/core/test/test_intrin128.avx512_skx.cpp

Excluding from source files list: <BUILD>/modules/core/test/test_intrin256.avx512_skx.cpp

Excluding from source files list: <BUILD>/modules/core/test/test_intrin512.avx512_skx.cpp

Registering hook 'INIT_MODULE_SOURCES_opencv_dnn': D:/opencv/opencv-4.5.1/modules/dnn/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake

opencv_dnn: filter out cuda4dnn source code

Excluding from source files list: <BUILD>/modules/dnn/layers/layers_common.avx512_skx.cpp

rgbd: CERES support is disabled. Ceres Solver is Required for Posegraph optimization

 

General configuration for OpenCV 4.5.1 =====================================

Version control: unknown

 

Extra modules:

Location (extra): D:/opencv/opencv_contrib-4.5.1/modules

Version control (extra): unknown

 

Platform:

Timestamp: 2021-01-13T06:58:06Z

Host: Windows 10.0.17134 AMD64

CMake: 3.10.3

CMake generator: MinGW Makefiles

CMake build tool: D:/MinGW/bin/mingw32-make.exe

Configuration: Release

 

CPU/HW features:

Baseline: SSE SSE2 SSE3

requested: SSE3

Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2

requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX

SSE4_1 (17 files): + SSSE3 SSE4_1

SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2

FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX

AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX

AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

 

C/C++:

Built as dynamic libs?: YES

C++ standard: 11

C++ Compiler: D:/Qt/Qt5.14.0/Tools/mingw730_64/bin/g++.exe (ver 7.3.0)

C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG

C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG

C Compiler: D:/Qt/Qt5.14.0/Tools/mingw730_64/bin/gcc.exe

C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG

C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG

Linker flags (Release): -Wl,--gc-sections

Linker flags (Debug): -Wl,--gc-sections

ccache: NO

Precompiled headers: NO

Extra dependencies: opengl32 glu32

3rdparty dependencies:

 

OpenCV modules:

To be built: aruco bgsegm bioinspired calib3d ccalib core cvv datasets dnn dnn_objdetect dnn_superres dpm features2d flann fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab ximgproc xobjdetect xphoto

Disabled: face python_bindings_generator python_tests world xfeatures2d

Disabled by dependency: -

Unavailable: alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev freetype hdf java julia matlab ovis python2 python3 sfm viz

Applications: tests perf_tests apps

Documentation: NO

Non-free algorithms: YES

 

Windows RT support: NO

 

GUI:

QT: YES (ver 5.14.0)

QT OpenGL support: YES (Qt5::OpenGL 5.14.0)

Win32 UI: YES

OpenGL support: YES (opengl32 glu32)

VTK support: NO

 

Media I/O:

ZLib: build (ver 1.2.11)

JPEG: build-libjpeg-turbo (ver 2.0.6-62)

WEBP: build (ver encoder: 0x020f)

PNG: build (ver 1.6.37)

TIFF: build (ver 42 - 4.0.10)

JPEG 2000: build (ver 2.3.1)

OpenEXR: build (ver 2.3.0)

HDR: YES

SUNRASTER: YES

PXM: YES

PFM: YES

 

Video I/O:

DC1394: NO

GStreamer: NO

DirectShow: YES

 

Parallel framework: none

 

Trace: YES (built-in)

 

Other third-party libraries:

Lapack: NO

Eigen: NO

Custom HAL: NO

Protobuf: build (3.5.1)

 

OpenCL: YES (no extra features)

Include path: D:/opencv/opencv-4.5.1/3rdparty/include/opencl/1.2

Link libraries: Dynamic load

 

Python (for build): NO

 

Java:

ant: NO

JNI: NO

Java wrappers: NO

Java tests: NO

 

Install to: D:/opencv/build4/install

-----------------------------------------------------------------

make成功
标题

 

install成功

mingw73_64  编译好的打包的Opencv4.5.1 普通版

https://download.csdn.net/download/weixin_44313363/14150767

mingw73_64  编译好的打包的Opencv_contrib-4.5.1

https://download.csdn.net/download/weixin_44313363/14150843

 

### 回答1: 在Windows 10系统中使用mingw32_64编译OpenCV开发包,可以通过以下步骤进行操作: 1. 首先,在GitHub上下载mingw-w64的压缩包,并解压到目标文件夹。然后将该文件夹的路径添加到系统的环境变量中,以便在命令提示符中使用。 2. 下载OpenCV的源代码,并解压到指定的文件夹。 3. 在命令提示符中,进入OpenCV源代码文件夹,创建一个新的文件夹,用于存放编译生成的文件。 4. 在命令提示符中,使用以下命令配置编译: ``` cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install .. ``` 这将配置编译过程,并生成适用于Mingw64的Makefiles。 5. 接下来,使用以下命令进行编译: ``` mingw32-make ``` 这将开始OpenCV编译过程。请注意,这可能需要一些时间,具体取决于您的系统配置和源代码大小。 6. 编译完成后,您可以使用以下命令进行安装: ``` mingw32-make install ``` 这将把编译生成的文件复制到指定的安装目录。 7. 最后,在您的项目中,使用#include <opencv2/opencv.hpp>来引用OpenCV库,并使用编译器的链接选项将编译生成的文件与您的代码连接在一起。 通过以上步骤,您可以在Windows 10系统中使用mingw32_64编译OpenCV开发包进行开发工作。请确保您的系统和编译器版本与教程相符,以获得最佳的编译效果。 ### 回答2: 在Windows 10系统中使用MinGW 7.3.0 64编译OpenCV开发包是可行的。下面是一些步骤和注意事项: 1. 准备MinGW编译环境:在Windows系统上安装MinGW编译器,并配置好环境变量以便于命令行中能够找到相应的编译工具。 2. 下载OpenCV源代码:从OpenCV的官方网站上下载最新的源代码,解压到一个目录中。 3. 配置OpenCV编译参数:进入OpenCV源代码目录,创建一个新的文件夹用于存放编译输出。在命令行(或者在CMake界面)中运行CMake命令,指定源代码目录和编译输出目录,并添加适用于MinGW编译器的参数。 4. 检查依赖项:确保你的系统已经安装了OpenCV所需的所有依赖项,例如CMake、Git等。 5. 生成OpenCV项目:根据你的目标平台配置,生成Makefile或者其他适用于你的编译环境的项目文件。 6. 编译和安装OpenCV:运行编译命令,这将编译OpenCV的源代码并生成库文件以及其他开发工具。然后,运行安装命令,将OpenCV的库文件和头文件复制到指定的目录中,以便在其他项目中使用。 7. 测试 OpenCV 安装:创建一个简单的OpenCV项目并编译运行,确保OpenCV正确安装并可以正常工作。 需要注意的是,使用MinGW编译编译OpenCV可能会遇到一些兼容性问题,并且可能无法完全发挥OpenCV的全部功能。因此,建议在Windows系统中使用官方支持的编译器,如Microsoft Visual Studio,以获得更好的兼容性和性能。 ### 回答3: 在Windows 10系统中使用Mingw-w64编译OpenCV开发包是可行的。Mingw-w64是一个基于MinGW的项目,可以在Windows上使用GNU Compiler Collection(GCC)编译工具链。 首先,需要下载并安装Mingw-w64。可以从官方网站(https://mingw-w64.org/doku.php)下载适合您系统的版本,并按照指导进行安装。安装完成后,需要将Mingw-w64的bin目录添加到系统的环境变量中,以便在任何位置都能够使用gcc和g++编译命令。 接下来,需要下载OpenCV的源代码,并解压到一个合适的目录中。可以从OpenCV官方网站(https://opencv.org/releases/)下载最新版本的源代码。 在解压后的OpenCV目录中,创建一个build文件夹,并在命令行中进入该目录: ``` cd <opencv_directory>/build ``` 在该目录中,执行cmake命令,指定编译器(gcc或g++),生成Makefile: ``` cmake -G "MinGW Makefiles" -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ .. ``` 接着,执行make命令进行编译和安装: ``` make make install ``` 编译过程可能会比较耗时,请耐心等待。 完成后,可以在系统上的任何位置使用Mingw-w64编译OpenCV开发包。在代码中,引入OpenCV的头文件,并链接相应的库文件即可开始开发。 需要注意的是,Mingw-w64编译器与Windows SDK之间存在一些兼容性问题。如果你的开发环境中还有其他需要Windows SDK的项目,可能需要进行一些额外的配置和调整。 总之,通过使用Mingw-w64编译OpenCV开发包,你可以在Windows 10系统上进行OpenCV相关的开发工作。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值