Still have SDL crash on exit

Hi, (under w2k with VC6) I still have a big crash on exit.
Link settings : nothing special, c++ code generation dll debug multithreaded
for every lib

Help appreciated :wink:

Iā€™ve desactivated all the code off my app, so now here is what is executing
(and still crashing) :

void oglInitialisation()
{
glClearColor(0,0,0,1);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST); // Indispensable !
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glDepthFunc(GL_LEQUAL);
glAlphaFunc(GL_GEQUAL,0.5f); // Je vois les flammes
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glEnable(GL_TEXTURE_2D); // Enables Texture Mapping
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(35.0f,(GLfloat)gWindowWidth/(GLfloat)gWindowHeight,1,
250.0f);
glEnableClientState(GL_VERTEX_ARRAY);
};

void SDLInitialisation() throw (CException)
{
if(SDL_Init(SDL_INIT_EVERYTHING)<0)
THROW("SDL Init error " + string(SDL_GetError()));

SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // tell SDL that the GL
drawing is going to be double buffered
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE,32); // size of depth
buffer
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); // we arenā€™t going to
use the stencil buffer
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0); // this and the next
three lines set the bits allocated per pixel -
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0); // - for the
accumulation buffer to 0
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);

MainWindow = SDL_SetVideoMode(gWindowWidth,gWindowHeight,32,SDL_OPENGL |
SDL_HWSURFACE | SDL_DOUBLEBUF);
if(MainWindow == NULL)
THROW("SDL MainWindow is null - " + string(SDL_GetError()));
}

int main(int argc, char *argv[])
{
// Iā€™ve removed the try catch bloc for posting in sdl mailing list
SDLInitialisation();
oglInitialisation();
SDL_Quit();
getch();
return 0;
}___________________________________________________________
Do You Yahoo!? ā€“ Une adresse @yahoo.fr gratuite et en fran?ais !
Yahoo! Mail : http://fr.mail.yahoo.com

Whoaā€¦

Noteworthy point: You are using the MFC exception class. This is pure
Microsoft specific, and what itā€™s behaviour with SDL would be, Iā€™ve got no clue
at all. I canā€™t even get it to compile - including the necessary afx.h for
CException, it complains ā€˜o:\program files\microsoft visual
studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H
already included. MFC apps must not #include <windows.h>ā€™ which sounds pretty
ominous right there. ( For other people trying to compile Chrisā€™ code out
there, worth mentioning you need to link OpenGL32.lib and glu32.lib as well as
sdl.lib and sdlmain.lib )

When I rewrite this code with C-style error handling, however, it seems to work
absolutely fine. Try this code:

/main.cpp***/
//Note: Need to link sdl.lib, sdlmain.lib, OpenGL32.lib, glu32.lib
#include <sdl.h>
#include <sdl_opengl.h>
#include <conio.h> //getch() - Microsoft specific, evil!

#define gWindowWidth 640
#define gWindowHeight 480
SDL_Surface *MainWindow=NULL;

int oglInitialisation()
{
glClearColor(0,0,0,1);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST); // Indispensable !
glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);
glDepthFunc(GL_LEQUAL);
glAlphaFunc(GL_GEQUAL,0.5f); // Je vois les flammes
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_CULL_FACE);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glEnable(GL_TEXTURE_2D); // Enables Texture Mapping
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(35.0f,(GLfloat)gWindowWidth/(GLfloat)gWindowHeight,1,250.0f);
glEnableClientState(GL_VERTEX_ARRAY);
return(0);
}

int SDLInitialisation()
{
if(SDL_Init(SDL_INIT_EVERYTHING)<0)
{
return(-1);
}

SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); // tell SDL that the GL
drawing is going to be double buffered
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE,32); // size of depth buffer
SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); // we arenā€™t going to use
the stencil buffer
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0); // this and the next three
lines set the bits allocated per pixel -
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
// - for the accumulation buffer to 0
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);

MainWindow = SDL_SetVideoMode(gWindowWidth,gWindowHeight,32,SDL_OPENGL
|SDL_HWSURFACE | SDL_DOUBLEBUF);
if(MainWindow==NULL)
{
return(-1);
}

return(0);
}

int main(int argc, char *argv[])
{
// Iā€™ve removed the try catch bloc for posting in sdl mailing list
if(SDLInitialisation()<0)
{
fprintf(stderr,ā€œCouldnā€™t init SDL - %s\nā€,SDL_GetError());
return(-1);
}

if(oglInitialisation()<0)
{
fprintf(stderr,ā€œCouldnā€™t init OpenGL!\nā€);
return(-1);
}

fprintf(stderr,ā€œSDL and OpenGL initialized. W00t!\nā€);

SDL_Quit();
fprintf(stderr,ā€œHave quit SDL. Waiting for keystrokeā€¦\nā€);
getch(); //Warning, getch() is not supported on all platforms
fprintf(stderr,ā€œKeystroke recieved. May the farce be with you.\nā€);
return 0;
}

/main.cpp ends/

Chris wrote:> Hi, (under w2k with VC6) I still have a big crash on exit.

Link settings : nothing special, c++ code generation dll debug multithreaded
for every lib

Help appreciated :wink:

Iā€™ve desactivated all the code off my app, so now here is what is executing
(and still crashing) :

___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran?ais ! Yahoo! Mail : http://fr.mail.yahoo.com

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Whoaā€¦

Noteworthy point: You are using the MFC exception class. This is pure
Microsoft specific, and what itā€™s behaviour with SDL would be, Iā€™ve got no
clue
at all. I canā€™t even get it to compile - including the necessary afx.h
for
CException, it complains ā€˜o:\program files\microsoft visual
studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :
WINDOWS.H
already included. MFC apps must not #include <windows.h>ā€™ which sounds
pretty
ominous right there. ( For other people trying to compile Chrisā€™ code out
there, worth mentioning you need to link OpenGL32.lib and glu32.lib as
well as
sdl.lib and sdlmain.lib )

No, no CException is not the MFC way to exceptionsā€¦ But my way based from
the ANSI way, and is defined like that :
#include
class CException : public exception
{
}

Sorry to forgot informations about this point :wink:

Iā€™ve found the reason of the crashesā€¦ The ā€œconflictā€ warning issued by the
linker IS harmfull and meaningfull.
Iā€™ve dumpbin sdmain.lib (both release and debug version) and see that the
debug version is linked to the non debug version of msvcrt !!
I supposed that the crashes was due to the mix between the two kind of libs,
and Iā€™ve tried to recompile sdlmain.lib several times and get ever the same
result.

So, as I was fed upā€¦ Iā€™ve directly included sdlmain.c in my project and
removed sdlmain.lib from link modules
and FINE ! it works FINE ! No more crashes, more leaks and (of course) no
more link warning !

But I really donā€™t understand why the visual C project in the SDL-1.2.5
distribution doesnā€™t link sdlmain.lib against the debug version of the
runtime libā€¦


Do You Yahoo!? ā€“ Une adresse @yahoo.fr gratuite et en fran?ais !
Yahoo! Mail : http://fr.mail.yahoo.com

----- Original Message -----
From: tsm@accesscomm.ca (Tyler Montbriand)
To:
Sent: Friday, November 29, 2002 7:13 PM
Subject: Re: [SDL] Still have SDL crash on exit

Honestly, it sounds like you forgot to #include ā€œSDL/SDL.hā€ in the file
that defines main(), or main()'s prototype isnā€™t:

int main(int argc, char *argv[])

like it should be (for SDL to call it)ā€¦

does this solve the problem?

-LorenOn Fri, 2002-11-29 at 12:02, Chris wrote:

----- Original Message -----
From: ā€œCorona688ā€
To:
Sent: Friday, November 29, 2002 7:13 PM
Subject: Re: [SDL] Still have SDL crash on exit

Whoaā€¦

Noteworthy point: You are using the MFC exception class. This is pure
Microsoft specific, and what itā€™s behaviour with SDL would be, Iā€™ve got no
clue
at all. I canā€™t even get it to compile - including the necessary afx.h
for
CException, it complains ā€˜o:\program files\microsoft visual
studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :
WINDOWS.H
already included. MFC apps must not #include <windows.h>ā€™ which sounds
pretty
ominous right there. ( For other people trying to compile Chrisā€™ code out
there, worth mentioning you need to link OpenGL32.lib and glu32.lib as
well as
sdl.lib and sdlmain.lib )

No, no CException is not the MFC way to exceptionsā€¦ But my way based from
the ANSI way, and is defined like that :
#include
class CException : public exception
{
}

Sorry to forgot informations about this point :wink:

Iā€™ve found the reason of the crashesā€¦ The ā€œconflictā€ warning issued by the
linker IS harmfull and meaningfull.
Iā€™ve dumpbin sdmain.lib (both release and debug version) and see that the
debug version is linked to the non debug version of msvcrt !!
I supposed that the crashes was due to the mix between the two kind of libs,
and Iā€™ve tried to recompile sdlmain.lib several times and get ever the same
result.

So, as I was fed upā€¦ Iā€™ve directly included sdlmain.c in my project and
removed sdlmain.lib from link modules
and FINE ! it works FINE ! No more crashes, more leaks and (of course) no
more link warning !

But I really donā€™t understand why the visual C project in the SDL-1.2.5
distribution doesnā€™t link sdlmain.lib against the debug version of the
runtime libā€¦


Do You Yahoo!? ā€“ Une adresse @yahoo.fr gratuite et en fran?ais !
Yahoo! Mail : http://fr.mail.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

No, sdlmain WAS excuted (step debug to be sure) but crashed on the last
steps (cleanup call)
The global step : winmain (inside sdlmain) -> consolemain -> main (my
main) -> then sdl cleanup -> crash in billā€™s code.
Iā€™m sure it was due to mix between debug and non debug code (non debug code
in sdlmain debug version).> ----- Original Message -----

From: linux_dr@yahoo.com (Loren Osborn)
To:
Sent: Friday, November 29, 2002 9:18 PM
Subject: Re: [SDL] Still have SDL crash on exit

Honestly, it sounds like you forgot to #include ā€œSDL/SDL.hā€ in the file
that defines main(), or main()'s prototype isnā€™t:

int main(int argc, char *argv[])

like it should be (for SDL to call it)ā€¦

does this solve the problem?

-Loren

On Fri, 2002-11-29 at 12:02, Chris wrote:

----- Original Message -----
From: ā€œCorona688ā€
To:
Sent: Friday, November 29, 2002 7:13 PM
Subject: Re: [SDL] Still have SDL crash on exit

Whoaā€¦

Noteworthy point: You are using the MFC exception class. This is pure
Microsoft specific, and what itā€™s behaviour with SDL would be, Iā€™ve got
no
clue

at all. I canā€™t even get it to compile - including the necessary afx.h
for
CException, it complains ā€˜o:\program files\microsoft visual
studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :
WINDOWS.H
already included. MFC apps must not #include <windows.h>ā€™ which sounds
pretty
ominous right there. ( For other people trying to compile Chrisā€™ code
out

there, worth mentioning you need to link OpenGL32.lib and glu32.lib as
well as
sdl.lib and sdlmain.lib )

No, no CException is not the MFC way to exceptionsā€¦ But my way based
from
the ANSI way, and is defined like that :
#include
class CException : public exception
{
}

Sorry to forgot informations about this point :wink:

Iā€™ve found the reason of the crashesā€¦ The ā€œconflictā€ warning issued by
the
linker IS harmfull and meaningfull.
Iā€™ve dumpbin sdmain.lib (both release and debug version) and see that the
debug version is linked to the non debug version of msvcrt !!
I supposed that the crashes was due to the mix between the two kind of
libs,
and Iā€™ve tried to recompile sdlmain.lib several times and get ever the
same
result.

So, as I was fed upā€¦ Iā€™ve directly included sdlmain.c in my project and
removed sdlmain.lib from link modules
and FINE ! it works FINE ! No more crashes, more leaks and (of course) no
more link warning !

But I really donā€™t understand why the visual C project in the SDL-1.2.5
distribution doesnā€™t link sdlmain.lib against the debug version of the
runtime libā€¦


Do You Yahoo!? ā€“ Une adresse @yahoo.fr gratuite et en fran?ais !
Yahoo! Mail : http://fr.mail.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Do You Yahoo!? ā€“ Une adresse @yahoo.fr gratuite et en fran?ais !
Yahoo! Mail : http://fr.mail.yahoo.com