Can't run Qt program connected with OpenCV

  • When I run program on QT creator, simple program which uses OpenCV.
    Have an error: cannot open file 'opencv243d.lib' (file not found)

    Here is my pro file.
    INCLUDEPATH += C:\Opencv243\opencv\build\include
    INCLUDEPATH += C:\opencv243\opencv\build\include\opencv2

    LIBS += -LC:\Opencv243\opencv_bin\lib

    Please help me.

  • First of all don't use in path a \ - replace it with /
    Then clear project, run qmake and try build/rebuild.
    If that doesn't help then make sure that opencv* are in PATH variable.

  • Can you paste here a pro file and some errors? It's looks that linker can't find lib or symbols in lib.

  • pro-file:
    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = Eye1
    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS += dialog.h

    FORMS += dialog.ui

    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../Opencv243/opencv/build/x64/vc10/lib/ -lopencv_core243d -lopencv_highgui243d -lopencv_imgproc243d -lopencv_features2d243d -lopencv_calib3d243d -lopencv_video243d -lopencv_objdetect243d -lopencv_ml243d -lopencv_legacy243d -lopencv_imgproc243d -lopencv_flann243d -lopencv_gpu243d
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../Opencv243/opencv/build/x64/vc10/lib/ -lopencv_core243d -lopencv_highgui243d -lopencv_imgproc243d -lopencv_features2d243d -lopencv_calib3d243d -lopencv_video243d -lopencv_objdetect243d -lopencv_ml243d -lopencv_legacy243d -lopencv_imgproc243d -lopencv_flann243d -lopencv_gpu243d

    INCLUDEPATH += $$PWD/../../Opencv243/opencv/build/include
    DEPENDPATH += $$PWD/../../Opencv243/opencv/build/include

    dialog.obj:-1: ошибка: LNK2019: unresolved external symbol "public: virtual __thiscall cv::VideoCapture::~VideoCapture(void)" (??1VideoCapture@cv@@UAE@XZ) referenced in function "public: virtual __thiscall Dialog::~Dialog(void)" (??1Dialog@@UAE@XZ)

    dialog.obj:-1: ошибка: LNK2019: unresolved external symbol "public: __thiscall cv::VideoCapture::VideoCapture(void)" (??0VideoCapture@cv@@QAE@XZ) referenced in function "public: __thiscall Dialog::Dialog(class QWidget *)" (??0Dialog@@QAE@PAVQWidget@@@Z)

  • My OpenCV version is 2.4.6, to include the PATHs and LIBS I did the code as follows, to this version of OpenCV you don't have to use the Cmake to compile the files, just add according to your system. Try to adapt the code to suit your situation.

    @QT += core

    QT -= gui

    TARGET = ShowImage
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    INCLUDEPATH += C:\opencv\build\include
    INCLUDEPATH += C:\opencv\include

    LIBS += -LC:\opencv\build\x86\vc11\lib

    Hope that Helps!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.