Pure c++ application without console. How?
-
Greetings.
I'm trying to create a plain c++ app. I chose New Project -> Plain C++ Project. My pro file looks like this:
TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG -= qt SOURCES += main.cpp
The source code:
#include <iostream> #include <windows.h> using namespace std; int main(int argc, const char* argv[]) { cout << "Hello World!" << endl; return 0; }
When I'm starting it - console window appears. I removed
CONFIG += console
line from the pro, and get an error:MSVCRTD.lib(crtexew.obj):-1: error: LNK2019: unresolved external symbol WinMain referenced in function __tmainCRTStartup
I returned line back and went to Project -> Build & Run -> Run and cleared Run in terminal checkbox. Now I don't see a window (hurrah!) but also I don't see any output to Application Output.
-
HI,
if you remove
CONFIG += console
qmake creates a Win32 application that not allows to write on the standard output.
If you want to create a non Qt application, I suggest to switch to CMake -
But I'm using Non-Qt Project (Plain C++ Project) from the beginning.
-
That's strange. Clearing the "Run in terminal" checkbox works for me and the output is redirected to the Application Output pane. Which Qt Creator version are you using?
-
Qt Creator 3.3.0.
-
Hi nikitablack,
could you clarify what exactly your problem or question is?
If you build a application without console and your entry point is a WinMain, you don´t get any output on standard streams. So the result is as expected, no output in Application Output. -
Could you try the latest version (3.4.0) ?
Also, do you start a debug session (the play button with a bug icon) or just run the app (the plain play button)? There seems to be a reported Creator bug where debug sessions don't redirect standard streams to the output. -
@nikitablack said:
But I'm using Non-Qt Project (Plain C++ Project) from the beginning.
Hi,
as I said you have to useCONFIG += console
if you need your application write on the standard output.OFF TOPIC: I suggested to switch to a CMake based project because using a qmake based project you require to install Qt only to build your application even if your application itself doesn't require Qt
-
@sneubert My entry point is
main
. And I want to have an output to Application Output, but not to console window.@Chris-Kawa Installed 3.4.0 - the same problem. Yes, I start a debug session. And you're right - it seems like a bug - because running an app (Ctrl+R) redirects output.
@mcosta said:
as I said you have to use
CONFIG += console
if you need your application write on the standard output.Yes, got it. Thanks.
-
Ok, now I got it.
This seems to be a bug. For projects build with msv2013 that are cmake based, without qt, I don´t get any output while debuggin. For the same build, without a debugger attached, the output is fine.