SDL console window questions

Started by
6 comments, last by c4c0d3m0n 16 years, 1 month ago
Hello I'm programming various SDL applications during these holidays. My IDE of choice is Code::Blocks. I use the default SDLapp template to create my applications. I've noticed that when I run my compiled program (under Windows at least), not only my SDL window is opened, but also a console. I have two questions:
  • I'd like to keep these consoles for now, but I want to display debug information in them. How can I access the console?
  • I'd also like to get rid of the console once I feel my application is mature enough to be sent to my friends. I don't want to be responsible for making their heads explode because they saw a console window ;) How do I get rid of the console?
Thanks in forward
Advertisement
Quote:Original post by c4c0d3m0n
  • I'd like to keep these consoles for now, but I want to display debug information in them. How can I access the console?


std::cout or printf should do it.

Quote:Original post by c4c0d3m0n
  • I'd also like to get rid of the console once I feel my application is mature enough to be sent to my friends. I don't want to be responsible for making their heads explode because they saw a console window ;) How do I get rid of the console?


  • Under Visual Studio there is an option of Win32 Console Application or Win32 Application. Choosing the former creates a console while the latter doesn't. I don't know if Code::Blocks has such an option, but you may want to look in you project settings.

    Quote:Original post by Simian Man
    Quote:Original post by c4c0d3m0n
    • I'd like to keep these consoles for now, but I want to display debug information in them. How can I access the console?


    std::cout or printf should do it.

    std::cout tells me that 'cout' is not part of 'std'. printf writes into a textfile called 'stdout.txt'. Neither outputs anything to the console.

    Quote:
    Quote:Original post by c4c0d3m0n
  • I'd also like to get rid of the console once I feel my application is mature enough to be sent to my friends. I don't want to be responsible for making their heads explode because they saw a console window ;) How do I get rid of the console?


  • Under Visual Studio there is an option of Win32 Console Application or Win32 Application. Choosing the former creates a console while the latter doesn't. I don't know if Code::Blocks has such an option, but you may want to look in you project settings.
    I found said option in the project options, thanks. Is there any preprocessor command that would archieve the same? I'd love to be able to do something like this:
    #define DEBUG#ifndef DEBUG  // Get rid of the console#endif
    you are probably running on /SUBSYSTEM:CONSOLE

    in MSVC++ you would do the following:
    go to project properties>Linker>System>Subsystem
    and change from Console to Windows
    •°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜˜”*°•..•°*”˜˜”*°•.˜”*°•.˜”*°•. Mads .•°*”˜.•°*”˜.•°*”˜˜”*°•.˜”*°•..•°*”˜.•°*”˜.•°*”˜ ˜”*°•.˜”*°•.˜”*°•..•°*”˜I am going to live forever... or die trying!
    Code::Blocks gets rid of the console window when
    setting the build target as Release (atleast for me).

    And you need to include iostream to use cout.
    Check out my devlog.
    Quote:Original post by c4c0d3m0n
    std::cout tells me that 'cout' is not part of 'std'. printf writes into a textfile called 'stdout.txt'. Neither outputs anything to the console.


    Oh yeah, my bad. Check out this page.
    Quote:Original post by Simian Man
    Quote:Original post by c4c0d3m0n
    std::cout tells me that 'cout' is not part of 'std'. printf writes into a textfile called 'stdout.txt'. Neither outputs anything to the console.


    Oh yeah, my bad. Check out this page.


    Ah thanks, the link you provided gave me the answer! Thanks again
        freopen( "CON", "w", stdout );    freopen( "CON", "w", stderr );


    Hmm, those lines of code enable output to the console, but only when I run my program from the console. If I run my program through explorer, a console window is created, but it stays empty. How do I gain access to this console aswell?

    This topic is closed to new replies.

    Advertisement