SDL: Executable Build and Run Issues

Started by
1 comment, last by SandPatrol 13 years, 9 months ago
Hi,

I have been trying to get SDL up and running with OpenGL and MinGW GCC on my new install of Windows 7; however, I seem to be having some issues. I had setup a sort of test project, and Eclipse CDT would "Build Successfully", but there would be no executable.

So, I decided to piece together the project one step at a time, building each stage so as to see where the error occurs.

I started with a simple hello world program, which worked fine. Then I added my SDL include directory to the eclipse build settings and set the lib location as well. I linked mingw32, SDLmain, and SDL in that specific order. Now when I build, the .exe file exists, and yet it does not run properly for some reason.

My code is as follows

#include <iostream>#include "SDL/SDL.h"int main( int argc, char* args[] ) {	std::cout << "Hello World!";	return 0;}


When running the .exe file, nothing happens, there is no output, and the Eclipse console says "<terminated>" as if something went wrong. Even running the .exe from a command prompt (cmd.exe) or an MSYS bash prompt has the same results: absolutely nothing, a simple blank line and then a new shell prompt.

Any help would be greatly appreciated.

Thanks!
Chris
Advertisement
This is just a guess, but check your various directories (e.g. the directory in which the executable resides) for a text file containing the text 'Hello World!'.

Unless you compile it with this feature deactivated, SDL redirects the standard output stream to a text file. I'm not sure where SDL does this exactly, but simply including the SDL header will most likely cause some SDL code to be executed, even though you're not actually invoking any SDL functions in your code. (This is because SDL does some macro trickery to co-opt the 'main' function.) If the 'redirect' is applied anywhere in that code, it could be occurring even though all you're doing is including the SDL header.

Again though, that's just a guess.
Well, that's good to know. That would be why I could not for the life of me find out why it wasn't working. There was indeed a text file with the contents "Hello World!". Now don't I feel sheepish, haha.

Thanks,
Chris

This topic is closed to new replies.

Advertisement