The OpenCV, the Qt Creator and the Windows 7

(For the ones who did not get the title: Il buono, il brutto, il cattivo)
After a few hours of googling and hacking we managed to set up OpenCV 2.3 in Qt Creator under Windows 7.

There are a lot of forum and blog posts out there about this but none of them uses the new OpenCV 2.3.

If you are full of reading linking errors like

undefined reference to `cvLoadImage’

you might have just arrived at the right post in the Internet.

After you have downloaded the binaries for Windows, you get a nice README suggesting this:

If you have problems add build\bin and one of build\{x86|x64}\{vc9\vc10\mingw}\bin to your system path (to use DLLs)


If you want to use Qt Creator with the default (and more standard) MinGW compiler not MSVC then you have just downloaded the wrong version of OpenCV since you will have to compile you own from source. You can get it at the same place you downloaded the the binaries from.

Useful guide here: http://opencv.willowgarage.com/wiki/MinGW#OpenCV2.2

Follow this guide to step 20, and dont forget to add the location of dll-s to your PATH after compiling OpenCV.

This post might also be helpful: http://www.barbato.us/2011/03/18/using-opencv2-within-qtcreator-in-windows-2/

Restart your Windows to let the PATH change take effect.

Here’s the code snippet from me .pro file which handles OpenCV.

LIBS += -LC:/OpenCV2.3MinGW/install/bin \
-llibopencv_core230 \
-llibopencv_highgui230

INCLUDEPATH += C:/OpenCV2.3MinGW/install/include \
C:/OpenCV2.3MinGW/install/include/opencv

Explanation: you have to insert the folder of your dll-s after -L and put the name of the desired dll-s after -l .

Happy hacking!

Leave a comment

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