Reputation: 4893
I would like to create a gui application with Qt, using opencv on Windows XP. I used both Qt and opencv before, but never together. Long story short, I'm unable to get opencv work with Qt.
As on all the forums I searched there are just little pieces of information scattered around, usually with no answer, I summarize here all the steps I've taken.
WITH_QT
checked)Highgui
was among the failed ones. The problem: Qt\4.6.3\src\corelib\global\qconfig.h
was not found. There was no qconfig.h
at all in the source I downloaded! I found some templates qconfig-large.h
, qconfig-small.h
etc., so I renamed one of them to qconfig.h
. Now I got a screen full of linker errors.qbenchmark.h
that includes QtTest/qbenchmarkmetric.h
which cannot be found..
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-g++.cmake:1 (INCLUDE):
include could not find load file:
C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-gcc.cmake
Call Stack (most recent call first):
C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/CMakeCXXInformation.cmake:59 (INCLUDE)
True, there is a Windows-g++.cmake
file in the Modules/Platform directory, but it references Windows-gcc.cmake
which does not exist!
Is there anyone who managed to build opencv with Qt support on Windows, and if yes, how?
Edit:
The problem is definitely with the Qt source. I managed to generate a MinGW makefile, and the build went all OK until it stopped in src/testlib/qtestsystem.h
because there was an include for QtCore/qelapsedtimer.h
which file is in a completely different directory! Does Qt release incomplete sources, or did I do something wrong?
Edit2
My torment continues. I cleaned everything and started anew. This time without even trying Visual Studio.
libopencv_core231
, etv.). I was very happy, but how wrong I was to celebrate that soon!!exited with code -1073741511
.exe
directly, outside of Qt Creator. It complained of a missing libstdc++-6.dll
.exe
is, but neither worked. I got "The procedure entry point _ZNSt9exceptionD2Ev could not be located in the dynamic link library libstdc++-6.dll." with both. This was in debug, so I tried release, and I got a similar error, with some other entry point not found.-static-libgcc -static-libstdc++
at the lines QMAKE_LFLAGS =
and QMAKE_LFLAGS_DEBUG =
in the file c:\Qt\mkspecs\win32-g++\qmake.conf
. This had no effect at all, even after restarting Qt Creator and rebuilding. If I don't copy the libstdc++-6.dll
, it still requires it.Of course, my simple test program without opencv runs from the exe
without needing any libstdc++-6.dll
, so that means my opencv build is responsible? I wanted to build opencv anew, but I cannot find any CMake settings referring to libstdc++ !
It might be a clue:
When using one of the libstdc++-6.dll
files, the error about a missing entrypoint mentions QtGui4.dll. I have a debug build, so it should be QtGui*d*4.dll, shouldn't it? Are there different libstdc++
s for debug and release? Either way, I tried to build release, but it didn't work either, same error
Is there no single person on this planet who tried using Qt with QtCreator and opencv 2.3 together on Windows xp, and succeeded? From searching all the forums and Qt archives, I could not find anyone. I'm ready to do the development in Linux, but I'll need a Windows release sooner or later anyway.
I'm trying to resist the temptation of the dark side, which whispers into my ears to forget Qt, MinGW, g++, opencv and try to hack together something in Visual Basic. Oh, the horrors!
Upvotes: 2
Views: 5407
Reputation: 31
Just FYI, I went basically through the same nightmare of combining Qt and OpenCV. This was my experience:
So what I can definitely tell is that using Qt and OpenCV for somebody who has little experience is far from trivial!
Upvotes: 3
Reputation: 93468
You might have an easier time configuring Qt Creator with OpenCV. This post shows how to achieve that, step-by-step! It displays several screenshots to aid in the process too.
Upvotes: 2
Reputation: 52407
You should build OpenCV from source, as you already did, it is no hassle. Note that recent versions of OpenCV can be built with and w/o Qt. Highgui optionally uses Qt! It is your choice if you build with or without Qt.
I used Qt libraries together with OpenCV for long time now. I never went for the SDK, instead I used the libs which are built for corresponding VS version. See here: http://qt.nokia.com/downloads/downloads#qt-lib
You can have it for VS2008 and VS2010, but earlier versions are also available built for VS2005. Old versions of Visual Studio suck so hard, why use them anyway.
Then I never had problems pulling it together in a CMake project. It goes along the lines of:
find_package(OpenCV)
find_package(Qt4 ${VOLE_MINIMUM_QT_VERSION} COMPONENTS QtCore QtGui)
find_package(Qt4 ${VOLE_MINIMUM_QT_VERSION} COMPONENTS QtOpenGL)
...
qt4_wrap_cpp(moc_sources ${vole_module_moc_sources})
qt4_wrap_ui(uic_sources ${vole_module_ui_sources})
qt4_add_resources(rcc_sources ${vole_module_rcc_sources})
You know, the usual stuff.
Five man weeks later you may probably get it run under Windows, while under GNU/Linux it is three commands in the shell.
Upvotes: 2