No stdout.txt under Windows Vista with VC++ 2008 Express

Hi,

I’m new to the development with libSDL and I have (for me) a big problem.

I have created a Win32 Application (no Console Application) in VC++ 2008
Express and try to print some text to the stdout. Normally the output
goes to a textfile called stdout.txt
But the file isn’t created. I have compiled the Debug Version of libSDL
(current SVN Revision) and copied the SDL.dll to C:\Windows\System32.
When I run the test samples the files are created.
Even if I run the Application from the Windows Explorer the files aren’t
created. What have I to do to enable these files?

Here is the code of my little test application:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

printf("Test\n");

atexit(SDL_Quit);

return 0;

}

Greets,
Christoph
-------------- next part --------------
A non-text attachment was scrubbed…
Name: seija.vcf
Type: text/x-vcard
Size: 139 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090103/5ae614c0/attachment.vcf

Does this work properly if you don’t include SDL? Otherwise, this sounds more like a VC++ problem, not an SDL problem.> ----- Original Message -----

From: seija@dragons-server.de (Christoph Friedrich)
To: SDL at lists.libsdl.org
Sent: Saturday, January 3, 2009 7:00:13 AM
Subject: [SDL] No stdout.txt under Windows Vista with VC++ 2008 Express

Hi,

I’m new to the development with libSDL and I have (for me) a big problem.

I have created a Win32 Application (no Console Application) in VC++ 2008 Express and try to print some text to the stdout. Normally the output goes to a textfile called stdout.txt
But the file isn’t created. I have compiled the Debug Version of libSDL (current SVN Revision) and copied the SDL.dll to C:\Windows\System32. When I run the test samples the files are created.
Even if I run the Application from the Windows Explorer the files aren’t created. What have I to do to enable these files?

Here is the code of my little test application:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

printf(“Test\n”);

atexit(SDL_Quit);

return 0;
}

Greets,
Christoph

When I run the following code (at the end of the mail) while I include
SDL it works perfect. So I think it is a problem in SDL (or I have
missed some option to define).

Here is the code that I tested:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

atexit(SDL_Quit);

FILE *stream ;
if((stream = freopen(“file.txt”, “w”, stdout)) == NULL)
exit(-1);

printf(“this is stdout output\n”);

stream = freopen(“CON”, “w”, stdout);

printf(“And now back to the console once again\n”);

return 0;

}

Mason Wheeler schrieb:> Does this work properly if you don’t include SDL? Otherwise, this sounds more like a VC++ problem, not an SDL problem.

----- Original Message ----
From: Christoph Friedrich <@Christoph_Friedrich>
To: SDL at lists.libsdl.org
Sent: Saturday, January 3, 2009 7:00:13 AM
Subject: [SDL] No stdout.txt under Windows Vista with VC++ 2008 Express

Hi,

I’m new to the development with libSDL and I have (for me) a big problem.

I have created a Win32 Application (no Console Application) in VC++ 2008 Express and try to print some text to the stdout. Normally the output goes to a textfile called stdout.txt
But the file isn’t created. I have compiled the Debug Version of libSDL (current SVN Revision) and copied the SDL.dll to C:\Windows\System32. When I run the test samples the files are created.
Even if I run the Application from the Windows Explorer the files aren’t created. What have I to do to enable these files?

Here is the code of my little test application:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

printf(“Test\n”);

atexit(SDL_Quit);

return 0;
}

Greets,
Christoph


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
A non-text attachment was scrubbed…
Name: seija.vcf
Type: text/x-vcard
Size: 139 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090103/374684cb/attachment.vcf

I have created a Win32 Application (no Console Application) in VC++ 2008
Express and try to print some text to the stdout. Normally the output
goes to a textfile called stdout.txt

I’ve encountered the same problem with VC++ 2005 when I started using SDL.
I worked around this by using fprintf instead. It does seem more of a quirk
in VC,
rather than a bug in SDL.

Cheers,
PeterFrom: seija@dragons-server.de (Christoph Friedrich)

Yes, by popular request I’ve removed the stdio redirection in SDL 1.3.

It’s actually kind of a pain, since I’m used to having stdout.txt too,
but you can use OutputDebugString() or fprintf to a file.

See ya,
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

I have a workaround:
*stdout = *stderr;

With this you can redirect the stdout to the stderr.txt file.
Why stdout don’t work with freopen I don’t know.

Greets
Christoph

Christoph Friedrich schrieb:

Hi,

I’m new to the development with libSDL and I have (for me) a big problem.

I have created a Win32 Application (no Console Application) in VC++
2008 Express and try to print some text to the stdout. Normally the
output goes to a textfile called stdout.txt
But the file isn’t created. I have compiled the Debug Version of
libSDL (current SVN Revision) and copied the SDL.dll to
C:\Windows\System32. When I run the test samples the files are created.
Even if I run the Application from the Windows Explorer the files
aren’t created. What have I to do to enable these files?

Here is the code of my little test application:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

printf(“Test\n”);

atexit(SDL_Quit);

return 0;
}

Greets,
Christoph


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
A non-text attachment was scrubbed…
Name: seija.vcf
Type: text/x-vcard
Size: 139 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090105/a77a4877/attachment.vcf

Okay now I have identified the problem:
In Visual C++ (or others - I couldn’t test it) when I stop the debugger
manually the file streams aren’t flushed.
So theres no output. If I flush the files manually it works fine.

Greets
Christoph

Christoph Friedrich schrieb:

I have a workaround:
*stdout = *stderr;

With this you can redirect the stdout to the stderr.txt file.
Why stdout don’t work with freopen I don’t know.

Greets
Christoph

Christoph Friedrich schrieb:

Hi,

I’m new to the development with libSDL and I have (for me) a big
problem.

I have created a Win32 Application (no Console Application) in VC++
2008 Express and try to print some text to the stdout. Normally the
output goes to a textfile called stdout.txt
But the file isn’t created. I have compiled the Debug Version of
libSDL (current SVN Revision) and copied the SDL.dll to
C:\Windows\System32. When I run the test samples the files are created.
Even if I run the Application from the Windows Explorer the files
aren’t created. What have I to do to enable these files?

Here is the code of my little test application:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

printf(“Test\n”);

atexit(SDL_Quit);

return 0;
}

Greets,
Christoph


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
A non-text attachment was scrubbed…
Name: seija.vcf
Type: text/x-vcard
Size: 139 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20090105/6487fdf3/attachment.vcf

In C and C++, usually the stream are only flushed when you issue a newline,
the buffer is full or they are manually flushed.

In any other situation there is no guarantee that your output will get
flushed.

Cheers,
Paulo

2009/1/5 Christoph Friedrich > Okay now I have identified the problem:

In Visual C++ (or others - I couldn’t test it) when I stop the debugger
manually the file streams aren’t flushed.
So theres no output. If I flush the files manually it works fine.

Greets
Christoph

Christoph Friedrich schrieb:

I have a workaround:
*stdout = *stderr;

With this you can redirect the stdout to the stderr.txt file.
Why stdout don’t work with freopen I don’t know.

Greets
Christoph

Christoph Friedrich schrieb:

Hi,

I’m new to the development with libSDL and I have (for me) a big problem.

I have created a Win32 Application (no Console Application) in VC++ 2008
Express and try to print some text to the stdout. Normally the output goes
to a textfile called stdout.txt
But the file isn’t created. I have compiled the Debug Version of libSDL
(current SVN Revision) and copied the SDL.dll to C:\Windows\System32. When I
run the test samples the files are created.
Even if I run the Application from the Windows Explorer the files aren’t
created. What have I to do to enable these files?

Here is the code of my little test application:

#undef NO_STDIO_REDIRECT

#include

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);

printf(“Test\n”);

atexit(SDL_Quit);

return 0;
}

Greets,
Christoph


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org