Windows cout using SDL

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows console,
is there anyway to do this? If not can I redirect the output stdout or
stderr to a text file?

Thank you,
Robert

Since you’re porting to Linux, you (hopefully) arn’t using any MFC or ATL,
so, just try compiling your source as a console app instead of a windows
app – this should give you nice access to stdin/stdout (if you’re using an
MSVC compiler, you’ll have to create a new project for it, and add all your
existing source to it, and set it up for SDK & whatever other libs you’re
using). If this doesn’t work, and you really need those stream objects like
cout, you could always open new ostream objects to other files, and use
those. If you have no experience doing that (showing my age here), you
could probably use the old tried-and-true printf() to much the effect that
you need.

  • Silicon> ----- Original Message -----

From: robert@littlebitlost.com (Robert Diel)
To:
Sent: Wednesday, October 29, 2003 2:47 AM
Subject: [SDL] Windows cout using SDL.

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows console,
is there anyway to do this? If not can I redirect the output stdout or
stderr to a text file?

Thank you,
Robert


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 10/22/2003

You are correct, I shouldn’t rely on SDL to do console output for me, I
should just add functions to log out to a file using the standard C++
functionality.

I assumed that I could not create a console app with SDL to display a
window, is this not correct? I assumed that it had to be a w32
application in order to use the SDL interface to graphical APIs in
Windows. If it can be a console app that displays both the console and
the SDL created window that would easily solve all my problems.

Thank you, again,

RobertOn Wed, 2003-10-29 at 03:47, John Silicon wrote:

Since you’re porting to Linux, you (hopefully) arn’t using any MFC or ATL,
so, just try compiling your source as a console app instead of a windows
app – this should give you nice access to stdin/stdout (if you’re using an
MSVC compiler, you’ll have to create a new project for it, and add all your
existing source to it, and set it up for SDK & whatever other libs you’re
using). If this doesn’t work, and you really need those stream objects like
cout, you could always open new ostream objects to other files, and use
those. If you have no experience doing that (showing my age here), you
could probably use the old tried-and-true printf() to much the effect that
you need.

  • Silicon

----- Original Message -----
From: “Robert Diel” <@Robert_Diel>
To:
Sent: Wednesday, October 29, 2003 2:47 AM
Subject: [SDL] Windows cout using SDL.

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows console,
is there anyway to do this? If not can I redirect the output stdout or
stderr to a text file?

Thank you,
Robert


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 10/22/2003


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Robert Diel wrote:

I assumed that I could not create a console app with SDL to display a
window, is this not correct?

Yes, this is NOT correct :wink: - ok, seriously, you can create a console
application that uses SDL to create a window, no problem. Just compile
the program as a console-app - no change in the SDL-code i required.

Regards,
\Mikkel Gjoel

for a SDL win32-app (non-console) normally stdout/stderr are redirected automatically
to the textfiles stdout.txt/stderr.txt, at least this worked for me (MSVC),

Thomas

You are correct, I shouldn’t rely on SDL to do console output for me, I
should just add functions to log out to a file using the standard C++
functionality.

I assumed that I could not create a console app with SDL to display a
window, is this not correct? I assumed that it had to be a w32
application in order to use the SDL interface to graphical APIs in
Windows. If it can be a console app that displays both the console and
the SDL created window that would easily solve all my problems.

This is rule #1 of computers: Never assume anything (especially that your
drive won’t crash)
Console applications have the same abilities to interface to the win32 API.
Personally, I build most of my programs using the console app stuff first –
it makes for easier debugging – especially in multi-threaded apps, when
MSVC’s debugger isn’t too reliable (as noted by some of my more recent
posts, I use alot of printf()'s to track down weird bugs.) The main
difference, in the actual code, is that windows-apps use WinMain(), while
console apps have main() – not to mention the handles and messages (from my
DOS background [I teach programming on DOS 3.0], these really scare me, so I
usually play with console apps exclusively when not using SDL – SDL’s
events stuff handles these for me, so I don’t have to deal with them at all
[this translates well to Direct3D – so I use OpenGL]). Anyways, back on
topic, you shouldn’t see too much difference when compiling a console app
compared to a windows app – just that you have an ugly black box there when
the program runs.

Anyways, good luck on the porting thing.

  • Silicon

Thank you, again,

Robert

Since you’re porting to Linux, you (hopefully) arn’t using any MFC or
ATL,

so, just try compiling your source as a console app instead of a windows
app – this should give you nice access to stdin/stdout (if you’re using
an

MSVC compiler, you’ll have to create a new project for it, and add all
your

existing source to it, and set it up for SDK & whatever other libs
you’re

using). If this doesn’t work, and you really need those stream objects
like

cout, you could always open new ostream objects to other files, and use
those. If you have no experience doing that (showing my age here), you
could probably use the old tried-and-true printf() to much the effect
that

you need.

  • Silicon

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows
console,

is there anyway to do this? If not can I redirect the output stdout
or

stderr to a text file?

Thank you,
Robert


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 10/22/2003


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 10/22/2003

----- Original Message -----
From: robert@littlebitlost.com (Robert Diel)
To:
Sent: Wednesday, October 29, 2003 4:36 AM
Subject: Re: [SDL] Windows cout using SDL.
On Wed, 2003-10-29 at 03:47, John Silicon wrote:

----- Original Message -----
From: “Robert Diel”
To:
Sent: Wednesday, October 29, 2003 2:47 AM
Subject: [SDL] Windows cout using SDL.

Just use regular output functions (cout if C++, printf() or whatever in C),
and Windows should automatically redirect them to stdout.txt and stderr.txt.

This has an advantage over creating a console app, in that a console window
doesn’t get opened every time the user runs the program.

If I remember correctly, if the user starts a console and launches the program
that way (even if the program wasn’t built as a console application), Windows
will just redirect stdout and stderr to the console.

So, really, you don’t have to change anything, with regards to stdout and
stderr anyway.

-Sean RidenourOn Wednesday 29 October 2003 2:47 am, Robert Diel wrote:

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows console,
is there anyway to do this? If not can I redirect the output stdout or
stderr to a text file?

Thank you,
Robert

Just use regular output functions (cout if C++, printf() or whatever in C),

(Or printf in C++.)

and Windows should automatically redirect them to stdout.txt and stderr.txt.

This has an advantage over creating a console app, in that a console window
doesn’t get opened every time the user runs the program.

If I remember correctly, if the user starts a console and launches the program
that way (even if the program wasn’t built as a console application), Windows
will just redirect stdout and stderr to the console.

Windows has nothing to do with stdout.txt and stderr.txt; it’s SDLmain
doing that.On Wed, Oct 29, 2003 at 03:31:13PM -0700, Sean Ridenour wrote:


Glenn Maynard

The output to stdout.txt and stderr.txt is what I’d read would happen,
however, this doesn’t happen with the program I am running as a Win32
Application. I did not compile the SDL library on my own, I used the
1.2.6 precompiled Win32 development binaries. Is it possible that the
functionality has been removed from this build? In SDL_main.cpp there
is an ifndef for NO_STDIO_REDIRECT that seems to redirect to a text
file. However, the project build definitions do not seem to indicate
that this is defined, which imply that it should redirect.

I guess my big question is should this just work? Should I be able to
do a cout << “Hello World” << endl; and boom it gets popped into the
stdio.txt in the same directory as the executable?

Thanks again for the help so far,
RobertOn Wed, 2003-10-29 at 16:31, Sean Ridenour wrote:

On Wednesday 29 October 2003 2:47 am, Robert Diel wrote:

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows console,
is there anyway to do this? If not can I redirect the output stdout or
stderr to a text file?

Thank you,
Robert

Just use regular output functions (cout if C++, printf() or whatever in C),
and Windows should automatically redirect them to stdout.txt and stderr.txt.

This has an advantage over creating a console app, in that a console window
doesn’t get opened every time the user runs the program.

If I remember correctly, if the user starts a console and launches the program
that way (even if the program wasn’t built as a console application), Windows
will just redirect stdout and stderr to the console.

So, really, you don’t have to change anything, with regards to stdout and
stderr anyway.

-Sean Ridenour


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

(MSVC6,Win32-App,precompiled SDL.dll 1.2.5 or 1.2.6)

cout redirection to stdout.txt seems to work only in release mode.
printf redirection to stdout.txt works for debug and release mode.
Maybe theres some trick to get cout>stdout.txt working in debug mode too,
I do not know,

Thomas> ----- Original Message -----

From: robert@littlebitlost.com (Robert Diel)
To:
Sent: Thursday, October 30, 2003 9:31 PM
Subject: Re: [SDL] Windows cout using SDL.

The output to stdout.txt and stderr.txt is what I’d read would happen,
however, this doesn’t happen with the program I am running as a Win32
Application. I did not compile the SDL library on my own, I used the
1.2.6 precompiled Win32 development binaries. Is it possible that the
functionality has been removed from this build? In SDL_main.cpp there
is an ifndef for NO_STDIO_REDIRECT that seems to redirect to a text
file. However, the project build definitions do not seem to indicate
that this is defined, which imply that it should redirect.

I guess my big question is should this just work? Should I be able to
do a cout << “Hello World” << endl; and boom it gets popped into the
stdio.txt in the same directory as the executable?

Thanks again for the help so far,
Robert

On Wed, 2003-10-29 at 16:31, Sean Ridenour wrote:

On Wednesday 29 October 2003 2:47 am, Robert Diel wrote:

Hello all,
I am currently porting an SDL application in Windows from Linux. In
the process I am in need of outputting some text to the windows console,
is there anyway to do this? If not can I redirect the output stdout or
stderr to a text file?

Thank you,
Robert

Just use regular output functions (cout if C++, printf() or whatever in C),
and Windows should automatically redirect them to stdout.txt and stderr.txt.

This has an advantage over creating a console app, in that a console window
doesn’t get opened every time the user runs the program.

If I remember correctly, if the user starts a console and launches the program
that way (even if the program wasn’t built as a console application), Windows
will just redirect stdout and stderr to the console.

So, really, you don’t have to change anything, with regards to stdout and
stderr anyway.

-Sean Ridenour


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I have watched in VC7 when writing to stdout.txt and stderr.txt. Those
files get created, then I think the debugger destroys them when it
closes the program. Maybe there’s some way to curb this behavior?

Jay

Thomas.Eder at nmi.at 10/31/03 4:54 AM >>>

(MSVC6,Win32-App,precompiled SDL.dll 1.2.5 or 1.2.6)

cout redirection to stdout.txt seems to work only in release mode.
printf redirection to stdout.txt works for debug and release mode.
Maybe theres some trick to get cout>stdout.txt working in debug mode
too,
I do not know,

Thomas> ----- Original Message -----

From: robert@littlebitlost.com (Robert Diel)
To:
Sent: Thursday, October 30, 2003 9:31 PM
Subject: Re: [SDL] Windows cout using SDL.

The output to stdout.txt and stderr.txt is what I’d read would happen,
however, this doesn’t happen with the program I am running as a Win32
Application. I did not compile the SDL library on my own, I used the
1.2.6 precompiled Win32 development binaries. Is it possible that the
functionality has been removed from this build? In SDL_main.cpp there
is an ifndef for NO_STDIO_REDIRECT that seems to redirect to a text
file. However, the project build definitions do not seem to indicate
that this is defined, which imply that it should redirect.

I guess my big question is should this just work? Should I be able to
do a cout << “Hello World” << endl; and boom it gets popped into the
stdio.txt in the same directory as the executable?

Thanks again for the help so far,
Robert

On Wed, 2003-10-29 at 16:31, Sean Ridenour wrote:

On Wednesday 29 October 2003 2:47 am, Robert Diel wrote:

Hello all,
I am currently porting an SDL application in Windows from Linux.
In

the process I am in need of outputting some text to the windows
console,

is there anyway to do this? If not can I redirect the output
stdout or

stderr to a text file?

Thank you,
Robert

Just use regular output functions (cout if C++, printf() or whatever
in C),

and Windows should automatically redirect them to stdout.txt and
stderr.txt.

This has an advantage over creating a console app, in that a console
window

doesn’t get opened every time the user runs the program.

If I remember correctly, if the user starts a console and launches
the program

that way (even if the program wasn’t built as a console
application), Windows

will just redirect stdout and stderr to the console.

So, really, you don’t have to change anything, with regards to
stdout and

stderr anyway.

-Sean Ridenour


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl