Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

SDL Program exits immidiatly ONLY on windows


  • Please log in to reply
4 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:49 PM

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.

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:49 PM

Posted 21 January 2010 - 01:23 PM

Try running it from a cmd window.

#3 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:49 PM

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 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:49 PM

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 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:07:49 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users