[SDL] SDL in dll - program crashes

Michael B. Edwin Rickert panda at industry.no-ip.com
Thu Jan 13 13:19:17 PST 2005

 From what I remember, the whole atexit() and related stuff is a real 
pain with DLL boundies. I'd reorganize my code like so:

cleanup_exe.c :

void cleanup_exe( void )
     //everything in the exe source that you'd normaly atexit()

cleanup_dll.c :

void cleanup_dll( void )
     //eveything in the dll source that you'd normally atexit()

main.c :

int main ( void )
     atexit( cleanup_exe );

Which IIRC should fix it.

Michal Rost wrote:
> Hi all,
> I put a part of my code, which contains creation of window an 
> utilization of screen (in SDL) in to a dll file, but problem is that 
> program, which uses this dll crashes in it's end, even that exact code 
> used in this dll worked outside of dll perfectly.
> I tryed to find where exactly program crashes and I found that it is 
> right after calling SDL_Quit(); So I took a look in to SDL specification 
> and I found a note, that there could be some problems with calling 
> atexit(); and SDL_Quit(); outside dynamic library...but when I removed 
> calling of these functions from my dll, program crashed with same error 
> message (close to the end of the application, I suppose on automatic 
> freeing of sdl).
> I am completly feckless, I searched this problem on google and other 
> forums, I found some posts with same problem, like this 
> http://twomix.devolution.com/pipermail/sdl/2004-April/061325.html, but 
> no usefull answers :(
> P.S.: I tryed to call SDL_INIT_NOPARACHUTE in SDL_Init() but it didn´t 
> help.
> Michal Rost
> ------------------------------------------------------------------------
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl

More information about the SDL mailing list