简体   繁体   中英

Error when compiling OpenCV for Qt

In order to use OpenCV in Qt, I have to compile it with MinGW by cmake.

Software are the following:

  • Qt 5.4.0
  • Opencv 2.4.11
  • CMake 3.2.2
  • MinGW version unknown, GCC 4.8.1

A fatal error occurred when I make file and I have no idea how to solve it at all.

[ 29%] Automatic moc for target opencv_highgui
Generating moc_window_QT.cpp
Exit code 0xc000007b

AUTOGEN: error: process for C:/opencvbuild/modules/highgui/moc_window_QT.cpp failed:
Exit code 0xc000007b

moc failed...
modules\highgui\CMakeFiles\opencv_highgui_automoc.dir\build.make:48: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui_automoc' failed
mingw32-make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui_automoc] Error 1

CMakeFiles\Makefile2:2066: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui_automoc.dir/all' failed
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui_automoc.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

These messages are shown in cmd.

Then I revised CMakeLists.txt, SET(CMAKE_AUTOMOC OFF)

modules\highgui\CMakeFiles\opencv_highgui_automoc.dir\build.make:64: recipe for target 'modules/highgui/qrc_window_QT.cpp' failed

Does anybody know a solution?

2 items to try.

  1. Try running make with VERBOSE=1 to increase the output on the makefile. That should give you a better idea of what is wrong.

  2. Try running with cmake-gui , then turn on advanced mode to check out what CMake found for the different Qt5 dependencies. On Mac, I install the latest Qt to my home directory, causing me to have to manually set variables. This is what it looks like for me.

在此处输入图片说明

在此处输入图片说明

Hopefully this provides some useful information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM