具有Qt创作者3.2及更高版本的OpenCV3.0. Qt 5.4构建错误"mingw32-make:*** [Makefile]错误3"; [英] OpenCV3.0 With Qt creator 3.2 & Qt 5.4 build error "mingw32-make: *** [Makefile] Error 3"

查看:404
本文介绍了具有Qt创作者3.2及更高版本的OpenCV3.0. Qt 5.4构建错误"mingw32-make:*** [Makefile]错误3";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Qt5.4和Amp编译了OpenCV 3.0. Windows 7计算机中的Qt Creator 3.2 64位.

I have compiled OpenCV 3.0 with Qt5.4 & Qt Creator 3.2 64 bits in a Windows 7 machine.

我一直在尝试执行最基本的OpenCV功能来加载图片.不幸的是,它给出了以下错误:

I have been trying to execute the most basic OpenCV functionalaty in loading a picture. Unfortunately it gives the following error:

C:\ Qt \ qt-5.4.0-x64-mingw492r0-sjlj \ qt-5.4.0-x64-mingw492r0-sjlj \ bin \ qmake.exe -spec win32-g ++ CONFIG + = release -o Makefile .. \ opencv_xpto \ opencv_xpto.pro C:/Users/Nelson Faria/文档/Programacao/opencv_xpto/opencv_xpto.pro:14:额外 测试表达式后的字符.处理项目文件时出错: .. \ opencv_xpto \ opencv_xpto.pro makefile:175:目标配方 'Makefile'失败mingw32-make:*** [Makefile]错误3 20:53:17: 过程 "C:\ Qt \ qt-5.4.0-x64-mingw492r0-sjlj \ mingw64 \ bin \ mingw32-make.exe" 以代码2退出.构建/部署项目opencv_xpto时出错 (套件:Qt 5.4)执行步骤"Make"时:20:53:17:经过的时间: 00:01.

C:\Qt\qt-5.4.0-x64-mingw492r0-sjlj\qt-5.4.0-x64-mingw492r0-sjlj\bin\qmake.exe -spec win32-g++ CONFIG+=release -o Makefile ..\opencv_xpto\opencv_xpto.pro C:/Users/Nelson Faria/Documents/Programacao/opencv_xpto/opencv_xpto.pro:14: Extra characters after test expression. Error processing project file: ..\opencv_xpto\opencv_xpto.pro makefile:175: recipe for target 'Makefile' failed mingw32-make: *** [Makefile] Error 3 20:53:17: The process "C:\Qt\qt-5.4.0-x64-mingw492r0-sjlj\mingw64\bin\mingw32-make.exe" exited with code 2. Error while building/deploying project opencv_xpto (kit: Qt 5.4) When executing step "Make" 20:53:17: Elapsed time: 00:01.

我要执行的代码如下:

   '#include <iostream>
    #include "opencv2/core/core.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv/cv.h"

    using namespace std;

    int main()
    {
        cout << "Hello World!" << endl;

        cv::Mat mat;
        mat = cv::imread("img.JPG");
        cv::namedWindow("hello");
        cv::imshow("hello",mat);

        cv::waitKey(0);

        return 0;
    }

最后是.pro

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

INCLUDEPATH += C:\opencv-mingw\install\include
LIBS += -LC:\\opencv-mingw\\install\\x64\mingw\\lib
    -lopencv_core300.dll \
    -lopencv_highgui300.dll \
    -lopencv_imgproc300.dll \
    -lopencv_features2d300.dll \
    -lopencv_calib3d300.dll

include(deployment.pri)
qtcAddDeployment()'

有人可以照亮我哪里出问题了吗?

Can someone inlight me where I gone wrong?

推荐答案

像这样纠正pro文件:

Correct pro file like that:

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

SOURCES += main.cpp

INCLUDEPATH += C:/opencv-mingw/install/include
LIBS += -LC:/opencv-mingw/install/x64/mingw/lib
    -lopencv_core300 \
    -lopencv_highgui300 \
    -lopencv_imgproc300 \
    -lopencv_features2d300 \
    -lopencv_calib3d300

include(deployment.pri)
qtcAddDeployment()


如果发生崩溃,则很有可能应用程序无法加载openCV dll.有两种方法可以解决此问题:


If you have a crash it is most probable that application is unable to load openCV dlls. There are two ways to fix this:

  • 将这些dll复制到带有可执行文件的目录中(大多数情况下或多或少是这样的:<your roject location>\..\debug-windows-64x-qt5-XXX
  • 添加到这些dll的路径变量位置

这篇关于具有Qt创作者3.2及更高版本的OpenCV3.0. Qt 5.4构建错误"mingw32-make:*** [Makefile]错误3";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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