Using OpenCV 2.3 with Qt in QtCreator


Staff member
as the release of OpenCV 2.3 is finally out, I wanted to compile and install this latest release on my system. As I often work with Qt and the QtCreator I of course wanted to be able to use it in my Qt projects. I've tried several methods now for some hours but always get errors:

<strong>First try: Compiling OpenCV 2.3 with WITH_QT</strong>

First I wanted to do it just like I did with the 2.2 release which worked fine for me. For this I followed this guide: <a href="" rel="nofollow"></a>

<li>Downloaded the source code</li>
<li>Set up CMake and told it to create MInGW Makefiles and specified the paths to the
in my C:\Qt... paths, checked WITH_QT and generated Makefiles for a release.</li>
<li>Built and installed it in a shell using
mingw32-make install

After this was completed successfully, I just needed to add the paths to my ".pro" file and was able to build some nice software that uses OpenCV (back at the time where I used the 2.2 release). Basically the last part is described here: <a href="" rel="nofollow"></a>

So I tried the same with the 2.3 release which compiled successfully just as with the old release. It even builds my example program but as soon as I execute it, it closes again and returns:

<strong>Second try: Using the pre-built OpenCV superpack using MinGW</strong>

As the first method didn't work I tried to use the pre-build versions. Though these don't have the WITH_QT enabled, I still wanted to try.

So I downloaded the superpack, extracted and put it somewhere. I then wanted to do the same as I did before and added the paths to the include folder and the dlls to my ".pro" file:

INCLUDEPATH+= C:/workspace/opencv/OpenCV2.3/build/include
LIBS+= C:/workspace/opencv/OpenCV2.3/build/x64/mingw/bin/*.dll

As compiler I used the MinGW compiler that comes with the current Qt SDK. But this crashes while building:

C:/workspace/opencv/OpenCV2.3/build/x64/mingw/bin/libopencv_calib3d230.dll: file not recognized: File format not recognized
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\CoinDetector.exe] Error 1
mingw32-make: *** [release] Error 2

<strong>Third try: Just like the second, but with using the VC2008 compiler</strong>

I tried the same thing with the vc2008 compiler that comes with the Qt SDK as well. So I selected the compiler and adapted the path in the ".pro" file to use:

LIBS+= C:/workspace/opencv/OpenCV2.3/build/x64/vc9/bin/*.dll

But this also crashes with an error that it can't read the dll:

C:/workspace/opencv/OpenCV2.3/build/x64/vc9/bin/opencv_calib3d230.dll : fatal error LNK1107: Ungültige oder beschädigte Datei: Lesen bei 0x2F0 nicht möglich.


So here my settings:

<li>Win7 Professional x64</li>
<li>Latest Qt SDK installed (4.7.3)</li>
<li>OpenCV 2.3 release</li>

<em><strong>Does anybody have an idea what might be wrong here? Would be glad for any help!</em></strong>