OpenCV ?

If you don’t know yet, OpenCV is a free library for image processing and computer vision applications. You can find more info from their web site.

So why QT ?

OpenCV can be used mainly in programs written in C and C++ (not only that, there are so many wrappers which enables you to work with OpenCV in other languages too). So talking about C++ why not using Visual C++ ?? Of course you can easily design GUIs. But why QT ?

QT is an C++ IDE which can be used to create gui applications easily. Find more info here.

The main advantage in using QT is that we can easily “integrate” the GUIs of OpenCV inside the GUIs created with QT.( Correct me if I’m wrong) What it means is that, It is hard to insert a video window inside a form created with C#. If you are using Visual Studio the window will open seperately to display the video. Think you got the point. Do some research, you’ll find the importance.

So let’s go to the topic..

Installing and configuring QT to work with OpenCV in Windows

Step 1:

FIrst we need to download and install the complete QT SDK. Download it here and get it installed. ( I have installed Qt SDK version 1.1.4 which includes the QT Creator IDE version 2.3 into the folder “C:\\QtSDK”)

Step 2:

Install CMake. Download it here. (I used CMake 2.8.2)

Step 3:

Download and extract it to a folder (In my case it is C:\\OpenCV2.2 ). I’m using the version 2.2 here. Newer versions also can be used in the same way i describe here with minor changes.

Step 4:

Now we need to comiple the OpenCV libraries. Run the CMake GUI.



Now give the source folder ( Mine is C:\\OpenCV2.2) and create a folder for the binaries to be build (my case it is C:\\OpenCV2.2MinGw ) and give the path to the  “Where to build binaries” box.

Step 5:

Now press configure. Select the generator as MinGW Makefiles.

And select Use default native compilers and press finish.

Step 6:

Wait some time and you’ll get a configuration screen.


If you like you can check the box for BUILD_EXAMPLES, so you can play with the examples 🙂

Check WITH_QT.

Now press configure again.


Step 7:

Now you’ll see a similar window to the last one and it asks for the path of qmake.exe. You need to puth the path to the qmake.exe here.

For me it is {code} C:\\QtSDK\\Desktop\\Qt\\4.7.4\\mingw\\bin\\qmake.exe{/code}

Press configure again.


Step 8:

Now press Generate, so it will try to generate the makefiles.


“Missing libgmp-10.dll” problem

Most probably you’ll get a message saying that missing libgmp-10.dll is missing. Solution is simple just add the bin folder of MinGW to the System Path variable

( My Computer -> View System Information -> Advanced -> Environment Variables -> System Variables -> Path -. Edit (or New) )

In my case this path is {code} C:\\QtSDK\\mingw\\bin {/code}.

Now you are ready to proceed. Press generate button of the CMake window again.


Step 9:

Now you’ll get the required files in the folder which you gave as build folder above. Now we need to compile these files with MinGW.

Open Command Prompt and change your directory to the build folder

{code} cd C:\\OpenCV2.2MinGw {/code}

Now give the command {code} mingw32-make {/code}

Have a nap because it takes some time for this process to complete 🙂


Step 10:

After completion of step 9 give the command {code} mingw32-make install {/code}

You are DONE!


Playing with QT :  Check whether everything is working fine..

Download this. Double Click and open the file. It will be opened with QT Creator.

In the file change the paths “INCLUDEPATH” and “LIBS”, if you used paths other than the ones I used.

Now run the project. Enjoy using QT 🙂


Good books I have come across :

  • For OpenCV with QT : OpenCV 2 Computer Vision Application Programming Cookbook book (Packt Publishers) (This is where I took the above simple example)
  • For learning OpenCV : Learning OpenCV – O’Reilly Media






Thilanka · December 17, 2011 at 11:08 pm

Thanks for sharing your information with us. Keep up the good work and wish you all the best!

Bandar · June 3, 2012 at 4:16 pm

Thank dude so much.
I have a question. I just followed steps in this link
It was nice and clear but I’ve got error
LNK1181: cannot open input file ‘opencv_core231.dll.lib’

Hopefully you help me

    Sanjaya · June 3, 2012 at 8:26 pm

    Please recheck the steps from the beginning to the end. Check whether the paths are set properly.
    And you can try this. Add ‘opencv_core231.dll’ and/or ‘opencv_core231.lib’ to the bin folder of the project and try n see..

      Bandar · June 4, 2012 at 1:47 pm

      Thanks dude very much.
      I did it but it didn’t work. Anyway, I wanna try your way then we’ll see.

        Sanjaya · June 4, 2012 at 2:06 pm

        It’s the “debug” folder not “bin”. Or u can even put them in the project root as well.
        However if it doesn’t work for you follow the above steps with OpenCV 2.2. It surely works..
        Thank you for your interest and politeness 🙂

Bandar · June 4, 2012 at 2:36 pm

I’m using openCV 2.3.1 and I’m facing new problem with CMake is there any way to install openCV without using CMake.
I know how to install openCV on visual C++ without CMake, so I’m sure about QT ? If it didn’t work, it’s better to me to swithc to Matlab. this library’s driving me crazy.

    Sanjaya · June 4, 2012 at 2:55 pm

    What’s the error you are getting with cmake ?
    File >> Delete cache and try again.

    Sanjaya · June 4, 2012 at 2:57 pm

    If you use pre-built binaries no need of using cmake. But for Mingw they don’t provide pre-built binaries I think..

johnny · August 8, 2012 at 2:23 pm

Thank you for this gold mine 🙂

Maryam · August 31, 2012 at 9:28 am

Thank you for your detailed guide. I’m using OpenCV 2.4.4, and following your steps. In step 5 it’s giving me this error: “Error in configuration process,
project files may be invalid”
I get the following in the message area: ”
CMake Error: The source directory “C:/OpenCV2.4″ does not appear to contain CMakeLists.txt.
Specify –help for usage, or press the help button on the CMake GUI.”

Could you please help me figure it out?


    Sanjaya · August 31, 2012 at 10:38 am

    I think the version is OpenCV 2.4.2 and you have downloaded OpenCV-2.4.2.exe from sourceforge.

    I tried this using this OpenCV-2.4.2.exe file and it works fine for me. As I feel the problem is that OpenCV-2.4.2.exe may have created a folder named “opencv” in your “C:/OpenCV2.4” folder. Check whether CMakeLists.txt file exists in “C:/OpenCV2.4/opencv”. If so you can give that path for the source directory and it will work fine 🙂

      Maryam · September 1, 2012 at 1:20 pm

      Hi Sanjaya,

      Thanks a lot for your guidance, I’m getting another error message now in the message area =)
      “CMake Error: CMake was unable to find a build program corresponding to “MinGW Makefiles”.”
      as well as a list of missing variables:

      The full message is:
      CMake Error: CMake was unable to find a build program corresponding to “MinGW Makefiles”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
      CMake Error: CMake was unable to find a build program corresponding to “MinGW Makefiles”. CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
      CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
      Missing variable is:
      CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
      Missing variable is:
      CMake Error: Could not find cmake module file:C:/OpenCV-MinGw/CMakeFiles/CMakeCXXCompiler.cmake
      CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
      Missing variable is:
      CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
      Missing variable is:
      CMake Error: Could not find cmake module file:C:/OpenCV-MinGw/CMakeFiles/CMakeCCompiler.cmake
      CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
      CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
      Configuring incomplete, errors occurred!

        Sanjaya · September 1, 2012 at 7:52 pm

        Try appending paths to bin folder of CMake and bin folder of MinGW to the PATH system variable.

          Martin Mueller · September 4, 2012 at 3:47 pm

          This one:
          or this one?

Isaac · September 16, 2012 at 10:08 pm


Very good tutorial. I followed carefully and achieve Qt + OpenCV 2.2.0 install.

Now, I wonder what that is supposed to make the test project whose link is at the end of the explanation.

I run and no error occurred but not only showed me MS-DOS console with the following message:

“Press RETURN to close this window …”.

Is that supposed to be what makes or is there something wrong with my installation?

Thanks in advance for any answers or help

Markus Eder · September 19, 2012 at 12:28 am

Thanks for the great instruction about the installation.
I see you understand the OpenCV very well.

I know it’s not the right place for this question but maybe you can help me.

Have you ever seen this exception in Qt while working with the OpenCV library:
Error – RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

Guilherme · September 30, 2012 at 11:49 pm

I’m using OpenCV 2.4.2 and the Cookbook from Laganière. I download your example, build it and tried to run. The console opens with the message:
“Press to close this window…”
and nothing happens.

After that, I’ve tried this:


int main(int argc, char *argv[]) {
//cv::Mat image= cv::imread("C:\\Users\\Guilherme\\Pictures\\testeimg.jpg");
//cv::imshow("Tulips", image);
std::cout << "Hello!" << std::endl;
return 1;

At this time, I’ve got the “Hello!” printed on the screen.
Hope you can help! Thanks.

Kaj Sanfridsson · October 23, 2012 at 1:32 am


i have big problems with installing the OpenCV on my computer

when i write the mingw32-make comand it starts to work but when i come to 29 % it fails and get this error message:

:(.text$_Z27qCleanupResources_window_QTv+0x24): undefined reference to `_imp___Z
collect2: ld returnerade avslutningsstatus 1
mingw32-make[2]: *** [bin/libopencv_highgui242.dll] Error 1
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2

mingw32-make: *** [all] Error 2

Do you have any clue whas going wrong? please help me

best regards kaj sanfridsson

    maki · November 3, 2013 at 11:19 pm

    We are not alone !

    1 year later, I have exactly the same problem : same step, same error message. Trying to build opencv 2.4.6 and “WITH_QT” enabled for highgui. (windows 7, QT version is 5.1, with mingw 4.8 32 bits).

    I have tried with visual studio 2010, with MinGw, with openGL, without openGL, spended days on google. in many tutorials, it looks simple (use nmake, type make, make-install, that’s all : nothing complicated is required). No way to get highgui with QT enabled.

    is there anybody in the world who can say what to do in this case ?

    best regards

Kaj Sanfridsson · October 23, 2012 at 1:59 am

hello again i just saw that i hade some swedish words in the error code i have translated them for you:

the only thing a changed was:

collect2: ld returnerade avslutningsstatus 1


collect2: ld returned ending status 1

:(.text$_Z27qCleanupResources_window_QTv+0x24): undefined reference to `_imp___Z
collect2: ld returned ending status 1
mingw32-make[2]: *** [bin/libopencv_highgui242.dll] Error 1
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2

mingw32-make: *** [all] Error 2

so now you maby have a clue what is wrong 😉
best regards kaj sanfridsson

amine · December 22, 2012 at 7:54 am

very good tutorial clear and effective
thank’s my freind!

Isma · April 3, 2013 at 3:35 pm

Hi !
Thanks for the tutoriel !
OpenCv was installed without problem & I used in a Qt console application without problem but when I used it with Qt GUI, some functions didn’t work. Any Idea?

Thanks =)

meii · July 10, 2013 at 3:39 pm

hi my friend. i have a problem when i’m going to install on command prompt. the installation stops on 38% with the error like
Kaj Sanfridsson’s problem. please please help.

Build OpenCV with Qt Creator on Windows | Vic's World · July 29, 2013 at 2:53 am

[…] 2. Like this:Like Loading… […]

Leave a Reply

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