BleepingComputer.com: SDL Program exits immidiatly ONLY on windows

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

SDL Program exits immidiatly ONLY on windows

#1 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 21 January 2010 - 01:15 PM

The title pretty much explain it but I have a simple SDL program written in C++, when compiled for Linux it works fine, it opens and waits for me to click close however when compiled for windows it opens and closes immediately just flashing for a split second.

Here is the part that waits for exit:

while(quit == false)

{

	// While there's an event to handle

	while(SDL_PollEvent(&event))

	{

		// If the user has Xed out the window

		if(event.type == SDL_QUIT)

		{

			// Quit the program

			quit = true;

		}

	}

}


And yes I have used "bool quit = false;" but its a little further up.

I just cant seem to find anything wrong with the code, heres the line i use to compile:

i386-mingw32-g++ -I/usr/bin/cross-tools/include/SDL main.cpp -o output.exe -L/usr/bin/cross-tools/lib -lmingw32 -lSDLmain -lSDL -lSDL_image -mwindows


Also it compile with no errors what so ever.

Thanks for any help you can offer me, Wolfy87.

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 21 January 2010 - 01:23 PM

Try running it from a cmd window.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 21 January 2010 - 02:02 PM

Nope that did'nt make a difference, could there be a command line option? So instead of -mwindows somthing like -msdl I can find one but maby somthing like it?

#4 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 23 January 2010 - 08:42 AM

I have worked out its because it cant load libpng12-0.dll, I have it in the same folder but it still can load it, dose this need to be included in the compile line?

#5 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 24 January 2010 - 02:54 PM

Fixed it :thumbsup: it turns out it was down to dll's, at first I thought I needed SDL.dll and SDL_image.dll, I actually also needed zlib1.dll and libpng12-0.dll.

For anyone that dose not know what to do with them or how to find them: They are all located in the lib folder of your compiler (Well they are on mingw32 running on Linux, not sure about anything else) and all you need to do is copy these dll's into the directory of your executable.

Hope this will help someone, Wolfy87.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users