Sign in to follow this  

SDL: disabling stdout.txt

This topic is 4340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to disable the creation of stdout.txt and stderr.txt without having to rebuild the SDL source? I'm not currently including <iostream>, or using std::cout, or std::cerr. (Not outputting to stdout, or stderr in any way) I checked both the VC6, and ming development zips for the library mentioned in: http://www.libsdl.org/faq.php?action=listentries&category=4#85 but I don't find it. (Must be too old of an answer?) I was hoping I don't have to recompile SDL if I don't have to, but I will try if I have to. (I had tried in the past, but I had problems on win32) -- thanks, monkey

Share this post


Link to post
Share on other sites
Quote:
Original post by ninmonkeys
(I had tried in the past, but I had problems on win32)


I'm thinking along the same things as ShoeStringGames, but if you have Visual Studio, recompiling is a piece of cake, you just select the NO_STDIO configuration and build that. If you use Dev-Cpp, then you will have to set one preprocessor definition to disable the stdio, but that should be it. If you run into troubles, I'm sure we can help you [smile]

Share this post


Link to post
Share on other sites
well, I needed to do this a while ago and I couldn't, so I did a simple hack(which was mentioned on SDL users mailing list I think). which is redirecting the output to somewhere else. but this doesn't solve the problem entirely.
to be clear, here is the sequence:
1- SDL gets initialized and creates stdout.txt
2- you use platform-specific functions to redirect stdout to anything(you can redirect it to NUL to throw it away).
3- anything written to stdout while the program is running will get redirected.
4- when SDL gets deinitialized it finds that stdout.txt is empty so it deletes it.

I can give you the code to do this but I'm not home now, if this solution suits you, tell me and I'll send you the code when I'm home.

Diaa Sami

Share this post


Link to post
Share on other sites
I had success by doing the following for the gcc compiler in DevC++:

- ensure -mwindows is not added as linker option in project
- ensure -lsdlmain is not added as linker option in project
- add SDL_win32_main.c to the project
- make the following change to the source file:


/* The standard output files */
#define STDOUT_FILE TEXT("stdout.txt")
#define STDERR_FILE TEXT("stderr.txt")

// *** ADD THIS TEXT BEFORE THE #ifndef BELOW ***
#define NO_STDIO_REDIRECT

#ifndef NO_STDIO_REDIRECT
#ifdef _WIN32_WCE
static wchar_t stdoutPath[MAX_PATH];
static wchar_t stderrPath[MAX_PATH];
#else
static char stdoutPath[MAX_PATH];
static char stderrPath[MAX_PATH];
#endif
#endif




Then you can use regular stdout output:

printf("Text\n");
fprintf(stdout, "Text\n");
cout << "Text" << endl; // haven't tried this, but it should work


Share this post


Link to post
Share on other sites
To clarify, I'm trying to prevent the files from being created at all, since this program is supposed to run on a CD, so it will not have write access to its working directory. ( It sounds like the include the source file will do that, but I haven't been able to get it working so far. )

Twixly: Thanks for the link, I didn't realize there was a more up to date faq.

I think i'm doing this right:
-I am not linking with the flag: -mwindows
-I am not linking wint the flag: -lSDLmain
-I placed the source at c:\programs\sdl_source, and include SDL_win32_main.c: #include "C:\Programs\SDL_source\SDL-1.2.9\src\main\win32\SDL_win32_main.c"

1) I get an error when trying to compile:
[Linker error] undefined reference to `SDL_main' 
My linker flags:
-lmingw32 -lSDL -lSDL_ttf
And i've tried this under both compiler, and c++ compiler
-DNO_STDIO_REDIRECT


2)If this doesn't work, what do I do to compile the source? I have "make" which is in dev-cpp/bin, but there is no "configure" binary.

MatrixCubed: Do I make that change in my source, or in SDL_win32_main.c? I tried both, and both ways i'm getting the same linker error:
  [Linker error] undefined reference to `SDL_main' ]

Share this post


Link to post
Share on other sites

This topic is 4340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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