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:
First try: Compiling OpenCV 2.3 with WITH_QT
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: http://knowtheabc.wordpress.com/2011/02/25/windows-opencv-and-qt-creator/
- Downloaded the source code
- Set up CMake and told it to create MInGW Makefiles and specified the paths to the
g++.exe
,gcc.exe
andqmake.exe
in my C:\Qt... paths, checked WITH_QT and generated Makefiles for a release. - Built and installed it in a shell using
mingw32-make
andmingw32-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: http://knowtheabc.wordpress.com/2011/02/25/opencv-in-qt/
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: -1073741515
Second try: Using the pre-built OpenCV superpack using MinGW
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
Third try: Just like the second, but with using the VC2008 compiler
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 ode开发者_运维百科r beschädigte Datei: Lesen bei 0x2F0 nicht möglich.
So here my settings:
- Win7 Professional x64
- Latest Qt SDK installed (4.7.3)
- OpenCV 2.3 release
Does anybody have an idea what might be wrong here? Would be glad for any help!
I just got my QT 4.7.3 to work with OpenCV2.3. Unfortunately I had to install VC++2008 Express Edition and the CDB Debugger from Microsoft (both are freebies from Microsoft). The good part is that I can now develop for Opencv in both IDE, VS 2008, and Qt Creator.
These are the settings of my .pro file:
INCLUDEPATH += C:/OpenCV2.3/build/include
INCLUDEPATH += C:/OpenCV2.3/build/include/opencv
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_calib3d230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_contrib230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_core230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_features2d230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_flann230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_highgui230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_imgproc230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_objdetect230.lib
LIBS += C:/OpenCV2.3/build/x86/vc9/lib/opencv_video230.lib
Remember, select the MSVC compiler in your Projects Settings
I have tried I don't know how many different approaches to make it work with MinGW, but not the right one so far. I'm also in Windows 7 64 bits...but I am developing for 32 bits, I suppose that if I use the x64 libraries I might get 64 bit projects to work.
Good luck,
Andres
Evident,
I got as far as the -1073741515 error also today. It turned out that the problem was related to the Qt dlls which I had in the release folder.... I was still using the mingw32 versions and not the msvc2008 ones. So I copied the msvc2008 dll files to my Release folder and I finally managed to run my Qt app.
精彩评论