[SOLVED] Qt5.2 and OpenCV 2.4.9

  • I am currently evaluating the commercial version of Qt5.2 enterprise on a PC running 64bit Win8.1

    I downloaded OpenCV 2.4.9 and used CMake and mingw to compile it. There are a whole host of tutorials on the web about making Qt and OpenCV work together, but I have not had success with any of them, I feel like I'm running around in circles

    Do I need to download and compile my own copy of Qt in order to make this work? Will that impact my current 5.2 enterprise/commercial (trial) installation?

    Any helpful pointers or tutorials would be greatly appreciated.

  • Lifetime Qt Champion


    What have you tried ? How did it fail ?

  • Hi, thanks for the reply. I'll have to go back through and "retry" tutorials, keeping specific notes of exactly what I did and what went wrong, in order to adequately answer you.

    In a nutshell, I downloaded latest OpenCV, extracted it, used CMake to generate a makefile, and then mingw to compile it. In the end I had no .LIB files. I tried again, this time specifying WITH_QT and then got a whole host of errors about missing Qt paths, which makes me suspect perhaps I have to download and compile it myself, but I'm unsure. Then I tried again, only instead of mingw, using Visual Studio 2010 which was already installed. Another long slew of errors.

    Since each of the tutorials seemed a few years old, and my now being at Qt5.2 I thought maybe somebody has an updated "how to " for letting me use OpenCV functions within Qt

  • Lifetime Qt Champion

    Essentially you need to ensure that you use the same compiler for both. IIRC OpenCV's binary package provides pre-built libraries for several compilers. You should look at that first before starting to compile.

  • ok so in theory, if I downloaded the sources for both OpenCV and Qt, and compiled them both with the same compiler, things should work.. I'll try that on another machine to see, as I have the commercial evaluation license in place and I'm not sure if compiling the sources will mess that up.

  • Lifetime Qt Champion

    Yes they should. IIRC OpenCV binary package comes with a set of library for almost all compiler flavors for Windows

  • I did finally get this to work.

    I downloaded the Qt 5.2.1 w/OpenGL / mingw version and installed it.
    Then I used the mingw version that came with that package, to compile OpenCV with QT.

    From there everything linked and ran properly. Thanks!

  • Lifetime Qt Champion

    You're welcome !

    Since you have everything working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

  • Can you do one thing for me?
    There is a open bug in OpenCV with mingw. The bug is described here:


    Can you add this line of code and verify if the bug in still open or not?

    @"cv::CascadeClassifier *a= new cv::CascadeClassifier();"
    "cv::CascadeClassifier a;"@

Log in to reply

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