Qt Creator + OpenCV: the program starts from .exe, but not from the editor

Well, I need to start working with OpenCV, and since I'm used to working with QtCreator, I try to make it all work together. I downloaded the latest version of OpenCV and compiled it using MinGW. Then I created this small console project to try it out. Below is the .pro file:

 QT += core QT -= gui TARGET = OpenCV_test4 CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp INCLUDEPATH += C:\\Librerias\\opencv2.3.1\\release\\include LIBS += -LC:\\Librerias\\opencv2.3.1\\release\\lib \ -lopencv_core231.dll \ -lopencv_highgui231.dll \ -lopencv_imgproc231.dll \ -lopencv_features2d231.dll \ -lopencv_calib3d231.dll 

Here is the main.cpp file:

 #include <QtCore/QCoreApplication> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // read an image cv::Mat image= cv::imread("img.jpg"); // create image window named "My Image" cv::namedWindow("OpenCV Window"); // show the image on window cv::imshow("OpenCV Window", image); // wait key for 5000 ms cv::waitKey(5000); return a.exec(); } 

(I tried this code with and without QCoreApplication strings)

Deal: it connects and builds, and when launched from QtCreator, only a terminal window appears with the name C:\QtSDK\QtCreator\bin\qtcreator_process_stub.exe with the line "Press RETURN to close this window ..."

But if I run .exe from the project folder, it works fine! Why can't QtCreator launch the application? I found this really strange, and I would appreciate any hint of it. It really isn't that important, but it hurts me to run .exe manually every time I change something to check how it works.

Thank you for your time:)

Additional Information:

  • I tried both versions of debugging and release, the problem is the same in them.
  • Debugging does not work; it never stops at any breakpoint.
  • I work on windows 7 proffesional x64

SOLVED, I don’t know what I did, it suddenly worked and continues to work, I would like to tell you how I fixed it, but I have no idea, such a strange thing: (

+4
source share
2 answers

Check projects β†’ Startup options β†’ Run in terminal. It should be turned on, but it seems to be turned off.

0
source

I ran into the same issue with QtCreator and OpenCL under Linux. A simple test program works after starting from the terminal, and after starting with QtCreator it does not work. I found that the reason was hardcoded LD_LIBRARY_PATH in the project startup environment settings. I dumped it on an empty line and this problem was having a problem.

0
source

Source: https://habr.com/ru/post/1396281/


All Articles