简体   繁体   English

OpenCV3.0与Qt创建者3.2和Qt 5.4构建错误“mingw32-make:*** [Makefile]错误3”

[英]OpenCV3.0 With Qt creator 3.2 & Qt 5.4 build error “mingw32-make: *** [Makefile] Error 3”

I have compiled OpenCV 3.0 with Qt5.4 & Qt Creator 3.2 64 bits in a Windows 7 machine. 我在Windows 7机器上用Qt5.4和Qt Creator 3.2 64位编译了OpenCV 3.0。

I have been trying to execute the most basic OpenCV functionalaty in loading a picture. 我一直在尝试在加载图片时执行最基本的OpenCV功能。 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/Documents/Programacao/opencv_xpto/opencv_xpto.pro:14: Extra characters after test expression. 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:测试表达后的额外字符。 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. 处理项目文件时出错:.. \\ 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(kit:Qt 5.4)执行步骤”Make“时20:53: 17:经过的时间:00:01。

The code I'm trying to execute is the following: 我正在尝试执行的代码如下:

   '#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;
    }

And finally the .pro 最后是.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? 在我出错的地方有人可以告诉我吗?

Correct pro file like that: 正确的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 \
    -lopencv_highgui300 \
    -lopencv_imgproc300 \
    -lopencv_features2d300 \
    -lopencv_calib3d300

include(deployment.pri)
qtcAddDeployment()


If you have a crash it is most probable that application is unable to load openCV dlls. 如果发生崩溃,应用程序很可能无法加载openCV dll。 There are two ways to fix this: 有两种方法可以解决这个问题:

  • copy those dlls to directory with your executable (most probaly more or less something like that: <your roject location>\\..\\debug-windows-64x-qt5-XXX 使用您的可执行文件将这些dll复制到目录(最常见的是或多或少的类似: <your roject location>\\..\\debug-windows-64x-qt5-XXX
  • add to the path variable location of those dlls 添加到那些dll的路径变量位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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