water
water

Reputation: 21

QT Creator exits with code 0 when running program

I am trying to run a simple OpenCV program in QT Creator 2.3, QT 4.7.4. I know the syntax is correct, but my program does not get run. When I run it, I simply get the qtcreator_process_stub.exe window with "Press <RETURN> to close this window...".

Why is this? My .pro file looks as such:

QT       += core
QT       -= gui

TARGET = myQtConsoleProject
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app
SOURCES += main.cpp

INCLUDEPATH += C:\\opencv\\release\\include

LIBS += -LC:\\opencv\\release\\lib \
-lopencv_core231.dll \
-lopencv_highgui231.dll \
-lopencv_imgproc231.dll \
-lopencv_features2d231.dll \
-lopencv_calib3d231.dll

The application output is

Starting C:\Users\chris\QT\myQtConsoleProject-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release\release\myQtConsoleProject.exe...
C:\Users\chris\QT\myQtConsoleProject-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release

\release\myQtConsoleProject.exe exited with code 0

The contents of my source code is as follows:

#include <stdio.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main() {
        printf("not outputting...\n");
        cv::Mat image= cv::imread("C:/temp/img.jpg");
        cv::namedWindow("My Image");
        cv::imshow("My Image", image);
        cv::waitKey(50000);
        return 1;
}

I've added C:\opencv\release\bin to my path.

Upvotes: 2

Views: 3841

Answers (1)

Tim Meyer
Tim Meyer

Reputation: 12600

The fact that your console window does not show any lines except the "Press to close" line means that your application does not output anything to the console.

I see you have a console project configured, meaning it has no GUI. But due to the fact that your program compiles fine this might not be a problem.

Can you post the code of your main() function? The behavior you describe seems to be related to your code, not the project configuration.

Upvotes: 1

Related Questions