Sign in to follow this  
c4c0d3m0n

SDL console window questions

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

    Share this post


    Link to post
    Share on other sites
    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

    Share this post


    Link to post
    Share on other sites
    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

    Share this post


    Link to post
    Share on other sites
    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.

    Share this post


    Link to post
    Share on other sites
    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.

    Share this post


    Link to post
    Share on other sites
    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

    Share this post


    Link to post
    Share on other sites
        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?

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    Sign in to follow this