SDL Help!

Started by
18 comments, last by Venerable Vampire 19 years, 11 months ago
Confused

this:
int main(int argc,char** argv) {
SDL_Surface *video = NULL;
SDL_Init(SDL_INIT_VIDEO);
video = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
if (!video) {
SDL_Quit();
return 1;
}
SDL_Quit();
return 0;
}
Gives me mucho errors, but changed the last argument of SDL_SetVideoMode is soemthing like SDL_SWSURFACE | SDL_NOFRAME gives me like 3 lines of errors instead of about 50.
I really have no clue what I''m doing. I even noticed that the main function is redefined as SDL_main, which causes the compiler to spout that it can''t find main. So I define main before I include the SDL header and then do main again below it. This is probably my problem, don''t know why I didn''t tell y''all that before. If anyone knows why my programs mess up I would love to know so I can get into some fun programming.

Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Advertisement
Sdl usually finds and replaces your main afaik.
It should look like that:
int main ( int argc, char* argv[] )  

Maybe that is the problem?

What did you add to the linker? I have to add -lSDLmain and -lSDL
Not sure how that works on a mac running os x though.

Can you post the new error messages?
And maybe add "----" above your signature?

[edited by - Clueless on May 10, 2004 4:15:05 PM]
Writing errors since 10/25/2003 2:25:56 AM
char** argv and char* argv[] are essentially the same.

And, judging from his error messages, there doesn''t seem to be any issues with included libraries or header files, since everything''s related to unreleased objects.

Frankly, you could just add SDL_Quit() before the return 0 in your original program and it should work fine.
sadly,

int main(int argc,char** argv) {
SDL_Surface *video = NULL;
SDL_Init(SDL_INIT_VIDEO);
video = SDL_SetVideoMode(640,480,32,SDL_NOFRAME);
SDL_Quit();
return 0;
}

does NOT work fine.

It generates the following errors:

2004-05-10 16:28:44.658 test[18558] *** _NSAutoreleaseNoPool(): Object 0x33dd00 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-10 16:28:44.658 test[18558] *** _NSAutoreleaseNoPool(): Object 0x33dd30 of class NSException autoreleased with no pool in place - just leaking
2004-05-10 16:28:44.658 test[18558] *** Uncaught exception: Error (1002) creating CGSWindow

test has exited due to signal 5 (SIGTRAP).


Also, I still don''t know why SDL is not giving my compiler a main method of its own. If I remove my main method before the SDL include it doesn''t run, exiting due to an unknown symbol _main error.

Totally confused but still hopeful.

--------------------------------------------------------
Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Are you using XCode/Project Builder? It''s somehow including Cocoa stuff and running it. I kinda doubt that SDL makes Cocoa calls internally so I''d have to guess that either your SDL framework is screwed up or you started a Cocoa project (accidentally) ?
Im using xcode and I start a standard tool project, then include the SDL framework. Like I mentioned above, the main method is screwed up and I use an override main method before the SDL header to make it even run as far as it does. I''m beginning to think the SDL framework IS screwed up. What version is the last one that worked with xcode? I downloaded the 1.2 version. I think it was 1.2, not sure.

--------------------------------------------------------
Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
It sounds like you''re not including the right headers and/or libraries. Basically, the header renames your main() function to SDL_main() which is then called by the "real" main() in the library. You must link to both SDL and SDLmain libraries for it to work.
What kind of library are we talking about? When I installed SDL, it put a .framework file in my ~/Library/Frameworks folder. I include that in my little test SDL program and include which, when I did the same thing with the glut framework includes the header from the library SDL. Is there another framework I need or am I missing something?

--------------------------------------------------------
Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Totally forgot about this post, but if anyone still cares, I found the problem!
Apparently the mac version of the sdl headers, when overwriting main, uses a lot of objective c calls, even some cocoa references to loading nibs and such. I was not running with the cocoa framework. I now have an app that runs under objective c using cocoa and the sdl libraries. I was wondering, is there any way to get around this and use c++ without cocoa, or am I stuck?

--------------------------------------------------------
Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Ask the SDL people, they have a mailing list with people who would know the answer to this question.

This topic is closed to new replies.

Advertisement