How to debug a .exe using OpenCV with QT in VS2015 or QtCreator?
-
Hi,
I'm a newbie in QT and OpenCV. I downloaded OpenCV's source code and compiled it with the cmake option -DWITH_QT=TRUE, so the highgui module can use QT to create its windows(it's much cooler than the original UI). But there is a problem. My exe runs well if I put it in the same directory with the opencv dlls and the QT dlls, but I cannot debug it in my IDE (VS or QtCreator) . If I try to run it directly in the IDE by Ctrl-F5, it will tell me: ' This application failed to start because it could not find or load the Qt platform plugin "windows" in "". Reinstalling the application may fix this problem.' Since I have put the directory of the OpenCV and QT in my PATH environment varable (I put the QT dlls and plugins and the OpenCV dlls togethor, by windeployqt.exe), I don't know why in the IDE it cannot find the plugins.
Thanks for any solutions. -
Hi and welcome to devnet,
Don't modify your system's PATH environment variable, that's bad practice. You might have other software also running with Qt installed and thus you would make them run with another version than the one they were compiled with.
I'd go with Qt Creator and then in the Run part of the Project panel, modify there the PATH environment variable to include the path to your OpenCV libraries.
-
@SGaist
Thanks for your advice. You mean I should delete the opencv's path from the system's PATH and just put it in my project? I tried and still can't debug my code in QtCreator. So would you mind telling me what kind of project should I create in the QtCreator and what should I write in the profile?
BTW:I'm not coding a QT program but just a small exe using opencv. It's when I run the exe, it will use highgui.dll and highgui will use Qt's dlls. It seems Qt can't find its plugins. -
Since your OpenCV uses Qt, I see two possibilities:
- Start Qt console project so you have the environment setup for Qt even if you don't use it directly
- Copy the environment of a Qt application to your OpenCV project to have it setup for Qt use.