Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Pure c++ application without console. How?
Forum Updated to NodeBB v4.3 + New Features

Pure c++ application without console. How?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 5.1k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nikitablack
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      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

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nikitablack
        wrote on last edited by
        #3

        But I'm using Non-Qt Project (Plain C++ Project) from the beginning.

        M 1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          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?

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nikitablack
            wrote on last edited by
            #5

            Qt Creator 3.3.0.

            1 Reply Last reply
            0
            • sneubertS Offline
              sneubertS Offline
              sneubert
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                1
                • N nikitablack

                  But I'm using Non-Qt Project (Plain C++ Project) from the beginning.

                  M Offline
                  M Offline
                  mcosta
                  wrote on last edited by
                  #8

                  @nikitablack said:

                  But I'm using Non-Qt Project (Plain C++ Project) from the beginning.

                  Hi,
                  as I said you have to use CONFIG += 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

                  Once your problem is solved don't forget to:

                  • Mark the thread as SOLVED using the Topic Tool menu
                  • Vote up the answer(s) that helped you to solve the issue

                  You can embed images using (http://imgur.com/) or (http://postimage.org/)

                  1 Reply Last reply
                  1
                  • N Offline
                    N Offline
                    nikitablack
                    wrote on last edited by
                    #9

                    @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.

                    1 Reply Last reply
                    0
                    • sneubertS Offline
                      sneubertS Offline
                      sneubert
                      wrote on last edited by
                      #10

                      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.

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved