• Advertisement
Sign in to follow this  

ubuntu SDL not outputting stdout.txt/stderr.txt or showing terminal window

This topic is 1922 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

I am using sdl with code::blocks I did not use the sdl preset because it creates a c++ project and I want a C program also the preset appears to have the same issue of not saving stdout.txt so I created a blank project and set up sdl in the project and I have tried both GUI application and console application and non of those target options seem to affect anything how do I either get a consol output or stdout.txt non of those are appearing. I am new to ubuntu gnu/linux so is it ubuntu or my program?

Share this post


Link to post
Share on other sites
Advertisement
On posix systems, SDL does not create stdout.txt and stderr.txt; those are purely Windows conventions. On posix systems (e.g. ubuntu), if you run your program directly from the terminal, you will see output in the terminal, instead of in those files.

For example:


akesterson@localhost:~$ cat printer.c
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
fprintf(stdout, "This is output.\n");
fprintf(stderr, "This is an error.\n");
return 0;
}
akesterson@localhost:~$ gcc -o printer printer.c
akesterson@localhost:~$ ./printer
This is output.
This is an error.
akesterson@localhost:~$ ./printer > stdout.txt
This is an error.
akesterson@localhost:~$ ./printer > stdout.txt 2>stderr.txt
akesterson@localhost:~$ cat stdout.txt
This is output.
akesterson@localhost:~$ cat stderr.txt
This is an error.


... If you want stdout.txt and stderr.txt, you'll have to manually redirect them. POSIX default behavior is that both output streams go to the terminal running the program. If you're not seeing this behavior, it's likely a result of the IDE you're using, and how it's launching/consuming the output. If you go to the directory with the compiled binary, and run it by hand, you should see the expected output in your terminal. Edited by akesterson

Share this post


Link to post
Share on other sites
Ok thank you I ran my program in terminal and now I am seing the output.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement