| Summary: | osx: uncaught exception NSInternalInconsistencyException, error creating CGSWindow | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Marc L <rhaamo> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | toomas.laasik |
| Version: | 1.2.14 | ||
| Hardware: | Other | ||
| OS: | Mac OS X 10.6 | ||
| Attachments: |
gdb backtrace
Fixed version of submitted file |
||
Created attachment 551 [details]
Fixed version of submitted file
I think that this is technically not a bug, but just the way how SDL works. To fix the submitted case you have to do 2 things: - #include <SDL/SDL.h> before main - add linker flag -Wl,-framework,Cocoa - (it is a also good idea to exit gracefully with SDL_Quit) SDL uses C preprocessor to redefine keyword "main". This is how it grabs control before any of your code executes and also makes program entry point cross-platform (eg windows had WinMain for graphical apps, but you still use main in SDL as entry point). The redefined main on OSX runs code that prepares native Cocoa framework for creating window (a bunch of NS... calls). If you manage to put main before you include SDL.h, then you'll get those "NS not properly initialized"-type errors. |
Created attachment 540 [details] gdb backtrace When trying a very simple SDL test program it fails with a traceback saying: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1002) creating CGSWindow' *** call stack here terminate called after throwing an instance of 'NSException' I've attached the gdb backtrace, and the test code is the following: /* * Built with * cc -g -ggdb3 -fno-inline -o test_sdl test_sdl.c -I/opt/local/include -L/opt/local/lib -lsdl -lsdlmain */ void run(); int main(int argc, char *argv[]) { run(); } #include <SDL/SDL.h> void run() { SDL_Init(SDL_INIT_VIDEO); SDL_SetVideoMode(640,480,0,SDL_OPENGL); }