antrofite_
antrofite_

Reputation: 59

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.

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/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.

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

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?

Upvotes: 0

Views: 2099

Answers (1)

Marek R
Marek R

Reputation: 37697

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()


If you have a crash it is most probable that application is unable to load openCV dlls. 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
  • add to the path variable location of those dlls

Upvotes: 0

Related Questions