Mingw32 opencv3.4编译错误

时间:2018-06-27 06:48:34

标签: c++ qt opencv cmake mingw32

我一直在尝试在QT上使用opencv。尽管按照我在互联网上可以找到的所有指南进行操作,但我并没有成功。使用CMAKE编译了opencv(使用本指南https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows),但是出现以下错误:

[ 50%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/container_avi.cpp.obj
[ 50%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_cmu.cpp.obj
[ 50%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj
C:\QTopencv\opencv\sources\modules\videoio\src\cap_dshow.cpp:114:21: fatal error: Aviriff.h: No such file or directory
 #include "Aviriff.h"
                     ^
compilation terminated.
modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:146: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj' failed
mingw32-make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_dshow.cpp.obj] Error 1
CMakeFiles\Makefile2:3052: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
mingw32-make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

除了指南https://wiki.qt.io/How_to_setup_Qt_and_openCV_on_Windows

,我还完成了这些操作
  • 在CMAKE中未选中的ENABLE_PRECOMPILED_HEADERS
  • 在CMAKE中检查了ENABLE_CXX11
  • opencv/sources/modules/videoio/src/cap_dshow.cpp文件的#define NO_DSHOW_STRSAFE行之前添加#include "DShow.h
  • OpenCVCompilerOptions.cmake文件中; 将add_extra_compiler_option(-Werror=non-virtual-dtor)更改为#add_extra_compiler_option(-Werror=non-virtual-dtor)

无论我做什么,我都无法成功。

  • UPDATE :同时使用cmake Windows win32-x86和Windows win64-x64版本进行编译,但结果相同。

  • UPDATE :取消选中“ BUILD_opencv_videoio”,并使用cmake Windows win32-x86版本进行编译,然后结果成功。现在我有了要使用的库文件。

    • 检查了WITH_QT
    • 未选中WITH_CUDA
    • CMAKE_BUILD_TYPE-“调试”(不带引号)。
    • 现在,我可以在创建的库中使用QT了,这是我的QT .pro文件:

    • 更新:但是我仍然不知道如何在不禁用“ BUILD_opencv_videoio”的情况下进行编译。任何帮助将不胜感激。

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

QT + =核心gui

greaterThan(QT_MAJOR_VERSION,4):QT + =小部件

目标= TX 模板=应用

INCLUDEPATH + = C:\ OCV \ opencv_build \ install \ include

LIBS + = -LC:\ OCV \ opencv_build \ bin \     libopencv_core341d \     libopencv_highgui341d \     libopencv_imgproc341d \     libopencv_features2d341d \     libopencv_calib3d341d \

来源+ = main.cpp \         mainwindow.cpp

HEADERS + = mainwindow.h

FORMS + = mainwindow.ui

0 个答案:

没有答案