Public Group

# No Output?

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

## Recommended Posts

So..I followed the SDL setup that I got off this page: http://pgdc.purdue.org/sdltutorial/sdl_setup.html (I got the link off the official SDL page) And the output of the program is..absolutely nothing. :| I'm not talking about a window opening and disapearing, when I use command prompt to run it, it just skips a line then quits. And it says it in the visual studio output window that it's loading a bunch of system dlls with no symbols loaded. (kernel32, user32, etc) Here's my exact code...which again, I just took off the page:
[SOURCE]
/* -- Include the precompiled libraries -- */
#ifdef WIN32
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")
#endif

#include "SDL.h"

int main(int argc, char **argv)
{
printf("\nHello SDL User!\n");

/* initialize SDL */
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( stderr, "Video initialization failed: %s\n",
SDL_GetError( ) );
SDL_Quit( );
}

SDL_Quit( );

return 0;
}
[/SOURCE]
Wierd...wierd indeed.

##### Share on other sites
You didn't #include the stdio.h header file, which is necessary for printf() and fprintf(). Try adding that, but calling printf() without stdio.h should have caused a compilation error, so that might not be the exact problem.

##### Share on other sites
Your processor zipped right through your program and reached the return statement so quickly, that you simply didn't see anything.

The two options you have are to run the program the way a console program is designed to be run - that is, using the command prompt or a batch file; or to insert some sort of a pause statement in your program.

The prevalent sentiment of GameDev these days is that pausing your programs is evil. However, if you must, you have the option of using std::cin.get(), which is probably your best option.

For whatever reason, that doesn't always work. I had programs which ignored the std::cin.get() function, and I'm not really sure why. In that case, you can go to the even-less-preferred option of using system( "pause" );.

##### Share on other sites
Quote:
 Original post by programwizardYou didn't #include the stdio.h header file, which is necessary for printf() and fprintf(). Try adding that, but calling printf() without stdio.h should have caused a compilation error, so that might not be the exact problem.

I've tried it with and without..I get the same thing.

##### Share on other sites
Quote:
 Original post by v0dKAYour processor zipped right through your program and reached the return statement so quickly, that you simply didn't see anything.The two options you have are to run the program the way a console program is designed to be run - that is, using the command prompt or a batch file; or to insert some sort of a pause statement in your program.The prevalent sentiment of GameDev these days is that pausing your programs is evil. However, if you must, you have the option of using std::cin.get(), which is probably your best option.For whatever reason, that doesn't always work. I had programs which ignored the std::cin.get() function, and I'm not really sure why. In that case, you can go to the even-less-preferred option of using system( "pause" );.

No, as I tried to point out, that's not the case because my command prompt which would display the output then allow me to give more commands went through it with nothing too.

##### Share on other sites
Now this is total guesswork since I don't know anything about SDL, but if you are compiling as a Windows app and linking to the SDL library, it is possible that int main() isn't actually the entry point.

Perhaps there is a WinMain hidden away in the SDL library that calls back your int main() function, so Vodka may well be right and it is just that printf is not getting correctly sent to the console since it is a Win app that is running, not a console program.

As I say, this is a total guess because I have no idea how SDL works. Do you have to compile SDL programs as of type Win32 application?

[EDIT] Just been on the SDL site and it says that to compile with Borland C++, you need to pass the -tW switch, which is the Win32 type switch, so while I am still not sure I am right, it does at least confirm the above suspicion.

There is also apparently an SDL_Main file it tells you to compile, which is where I would suspect the actual WinMain would reside.

##### Share on other sites
SDL automatically redirects stdout to a file called "stdout.txt" for Windows applications. Check around for this file in your program's directory. It probably has your output. [smile]

##### Share on other sites
Quote:
 Original post by Simian ManSDL automatically redirects stdout to a file called "stdout.txt" for Windows applications. Check around for this file in your program's directory. It probably has your output. [smile]

Thank you..I found it! Finally...my SDL is (possibly) setup right! And it only took me 2 months to figure it out. :|

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
17

• 10
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999991
×