Configuring Qt for Windows Projects to Use OpenCV 4.1.0

I usually build OpenCV with the BUILD_opencv_world option which makes it quite easy to configure my Qt projects and work fast. But when it comes to deploying OpenCV powered applications, I still prefer to use the modular and default OpenCV build in order to deploy only the required DLLs and end up with a smaller installer file size.



Here is the snippet I use in my Qt project file in order to add OpenCV 4.1.0 support to my Qt for Windows project in a proper way:

win32 {
    INCLUDEPATH += "C:/opencv/include"
    LIBS += -L"C:/opencv/lib"

    Debug {
        LIBS += \
            -l"opencv_calib3d410d" \
            -l"opencv_core410d" \
            -l"opencv_dnn410d" \
            -l"opencv_features2d410d" \
            -l"opencv_flann410d" \
            -l"opencv_gapi410d" \
            -l"opencv_highgui410d" \
            -l"opencv_imgcodecs410d" \
            -l"opencv_imgproc410d" \
            -l"opencv_ml410d" \
            -l"opencv_objdetect410d" \
            -l"opencv_photo410d" \
            -l"opencv_stitching410d" \
            -l"opencv_video410d" \
            -l"opencv_videoio410d"
    }

    Release {
        LIBS += \
            -l"opencv_calib3d410" \
            -l"opencv_core410" \
            -l"opencv_dnn410" \
            -l"opencv_features2d410" \
            -l"opencv_flann410" \
            -l"opencv_gapi410" \
            -l"opencv_highgui410" \
            -l"opencv_imgcodecs410" \
            -l"opencv_imgproc410" \
            -l"opencv_ml410" \
            -l"opencv_objdetect410" \
            -l"opencv_photo410" \
            -l"opencv_stitching410" \
            -l"opencv_video410" \
            -l"opencv_videoio410"
    }
}

Needless to say, you must replace “C:/opencv/” in the preceding code with the path on your computer. Good luck!



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.