Results 1 to 8 of 8

Thread: Using Creator to create standard console applications

  1. #1
    Join Date
    May 2011
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Question Using Creator to create standard console applications

    Hey,
    I was just wondering if i can also use the Qt Creator to code standard console applications. I tried it with just an hello world app
    Qt Code:
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int main(void)
    5. {
    6. cout << "Hello World";
    7. return 0;
    8. }
    To copy to clipboard, switch view to plain text mode 
    and it compiled fine. But when i start the .exe its says that various .dll's are needed to run it which makes not much sense. So, do i have to to check something that it compiles without Qt stuff, or is it not possible?

  2. #2
    Join Date
    Sep 2011
    Posts
    9
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: Using Creator to create standard console applications

    Hello, I understand you used qmake. Did you remember to edit your project file (.pro) to exclude linking rules and include paths related to Qt ? Something like:
    Qt Code:
    1. CONFIG -= qt
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2011
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using Creator to create standard console applications

    No, I did not, but the idea points probably in the right direction
    I tried
    Qt Code:
    1. CONFIG -= qt
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. CONFIG -= qt
    2. CONFIG += console
    To copy to clipboard, switch view to plain text mode 

    But both worked not, my application is still not running

  4. #4
    Join Date
    Sep 2011
    Posts
    9
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: Using Creator to create standard console applications

    Does it complain about Qt dlls or compiler related dlls? If you compiled using mingw it will require both the mingwm10 and the libgcc dlls (I'm assuming from your post you're under Windows) and similar requirements should be met with MSVC. You should do a static compile to deploy a single .exe file (I'm not sure about the licensing implications of such, though). Should you decide to keep linking dynamically, you should deploy the required dlls alongside the executable file.
    Last edited by bah; 5th September 2011 at 16:34.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using Creator to create standard console applications

    Your program, compiled with a PRO file like:
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5.  
    6. CONFIG -= qt
    7.  
    8. # Input
    9. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 
    Has no dependencies on any part of Qt. I does have dependencies on system and possibly compiler libraries (MinGW and gcc). Since you don't share the error messages we cannot be specific.

  6. #6
    Join Date
    May 2011
    Posts
    27
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using Creator to create standard console applications

    There are no error messages, the code compiles fine. I added a cin so that the console does not close immediatly:
    Qt Code:
    1. #include <iostream>
    2.  
    3. using namespace std;
    4.  
    5. int main(void)
    6. {
    7. int var = 0;
    8. cout << "Hello world" << endl;
    9. cin >> var;
    10. return 0;
    11. }
    To copy to clipboard, switch view to plain text mode 

    when I add mingwm10.dll and libgcc_s_dw2-1.dll the programm gets executed, but nothing happens. No console pops up

    My project file looks now like the one from Chris. I don't really know what other informations you need.

  7. #7
    Join Date
    Sep 2011
    Posts
    9
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    2

    Default Re: Using Creator to create standard console applications

    Try to see the output on a command prompt/console run.

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Using Creator to create standard console applications

    No console pops up
    Like all "Hello World" C programs it must be run from a command prompt.

    No console pops up because your code does not include a WinMain entry point, code to create a Windows console, connect the stdin and stdout streams, and make it act as expected. If you use the Qt core then you can have this done for you (CONFIG += console). Since you do not want Qt dependencies you must do it for yourself. Have a look at http://dslweb.nwnexus.com/~ast/dload/guicon.htm (you might have to adjust for MingW).

Similar Threads

  1. Using the standard library with qt creator
    By DragonLance156156 in forum Qt Tools
    Replies: 12
    Last Post: 3rd February 2016, 09:59
  2. Replies: 2
    Last Post: 18th April 2011, 09:36
  3. Qt Creator console window in Qt Creator
    By radith in forum Qt Tools
    Replies: 2
    Last Post: 28th February 2011, 11:15
  4. Replies: 2
    Last Post: 16th August 2010, 06:34
  5. How to create single exe for Console & GUI mode
    By summer_of_69 in forum Qt Programming
    Replies: 4
    Last Post: 11th June 2009, 08:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.