Can't run SDL apps in OSX 10.6

Hi,

I’m trying to run a simple SDL test under OSX 10.6 but it fails, saying:

*** Terminating app due to uncaught exception
’NSInternalInconsistencyException’, reason: ‘Error (1002) creating
CGSWindow’
*** call stack here
terminate called after throwing an instance of ‘NSException’

The test code is the following:

… snip …
/*

  • 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);
}
… snip …

Versions:

  • OSX 10.6.5
  • SDL 1.2.14 from MacPorts

Have I missed something ?

Thanks.

Might be because there is no surface linking to SDL_SetVideoMode(640,480,0,SDL_OPENGL);
add these two lines

SDL_Surface *screen;

screen = SDL_SetVideoMode(640,480,0,SDL_OPENGL);

Same problem.

This example works with SDL 1.3, but i need to use the 1.2.x :(On Fri, Dec 10, 2010 at 11:51 PM, image28 wrote:

Might be because there is no surface linking to
SDL_SetVideoMode(640,480,0,SDL_OPENGL);
add these two lines

SDL_Surface *screen;

screen = SDL_SetVideoMode(640,480,0,SDL_OPENGL);

I’m trying to run a simple SDL test under OSX 10.6 but it fails, saying:

*** Terminating app due to uncaught exception
’NSInternalInconsistencyException’, reason: ‘Error (1002) creating
CGSWindow’
*** call stack here
terminate called after throwing an instance of ‘NSException’

Versions:

  • OSX 10.6.5
  • SDL 1.2.14 from MacPorts

Have I missed something ?

Try the SDL.framework from the official binary DMG with the starter
Xcode projects from the dev-extras DMG. I haven’t seen your error. I
just tried the basic Xcode template project and the OpenGL Atlantis
template project and both worked fine for me under 10.6.5/1.2.14.

-Eric–
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/

But i’m not using XCode here, XCode examples works but I don’t want to use it.On Sat, Dec 11, 2010 at 12:06 PM, Eric Wing wrote:

I’m trying to run a simple SDL test under OSX 10.6 but it fails, saying:

? *** Terminating app due to uncaught exception
’NSInternalInconsistencyException’, reason: ‘Error (1002) creating
CGSWindow’
? *** call stack here
? terminate called after throwing an instance of ‘NSException’

Versions:
?- OSX 10.6.5
?- SDL 1.2.14 from MacPorts

Have I missed something ?

Try the SDL.framework from the official binary DMG with the starter
Xcode projects from the dev-extras DMG. I haven’t seen your error. I
just tried the basic Xcode template project and the OpenGL Atlantis
template project and both worked fine for me under 10.6.5/1.2.14.

My apologies if the stuff below sounds stupid or ignorant but

… snip …
/*

  • 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);
}
… snip …

main() enters, calls run() which initialises SDL then run() returns and
main() returns (without actually returning an exit code). The SDL event
loop never entered.

If some threads are started when SDL talks to OpenGL (don’t know if that
happens or not) which would need to be synchronised by the event loop,
that might be an issue.

Also, does SDL return any error code from either calls?
Do you know which one fails?

(Note that I have no idea what libsdlmain is, I only ever linked against
libsdl on Linux)

Regards,

Zoltan

My apologies if the stuff below sounds stupid or ignorant but

… snip …
/*
?* 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);
}
… snip …

main() enters, calls run() which initialises SDL then run() returns and
main() returns (without actually returning an exit code). The SDL event
loop never entered.

If some threads are started when SDL talks to OpenGL (don’t know if that
happens or not) which would need to be synchronised by the event loop,
that might be an issue.

Also, does SDL return any error code from either calls?
Do you know which one fails?

I’ve the call stack :

2010-12-11 15:42:01.629 test_sdl[40997:903] *** Terminating app due to
uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Error
(1002) creating CGSWindow’
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff8909e7b4
__exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff85a870f3
objc_exception_throw + 45
2 CoreFoundation 0x00007fff8909e5d7
+[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff8909e564
+[NSException raise:format:] + 148
4 AppKit 0x00007fff82a92ee2
_NSCreateWindowWithOpaqueShape2 + 473
5 AppKit 0x00007fff82a27489 -[NSWindow
_commonAwake] + 1214
6 AppKit 0x00007fff82a2416e -[NSWindow
_commonInitFrame:styleMask:backing:defer:] + 1501
7 AppKit 0x00007fff82a22dfa -[NSWindow
_initContent:styleMask:backing:defer:contentView:] + 1396
8 AppKit 0x00007fff82a22883 -[NSWindow
initWithContentRect:styleMask:backing:defer:] + 42
9 libSDL-1.2.0.dylib 0x0000000100051c7a
-[SDL_QuartzWindow initWithContentRect:styleMask:backing:defer:] + 349
10 libSDL-1.2.0.dylib 0x000000010004e1fe
QZ_SetVideoWindowed + 832
11 libSDL-1.2.0.dylib 0x000000010004eabc
QZ_SetVideoMode + 169
12 libSDL-1.2.0.dylib 0x00000001000403ec
SDL_SetVideoMode + 655
13 test_sdl 0x0000000100000eea run + 43
14 test_sdl 0x0000000100000ebd main + 25
15 test_sdl 0x0000000100000e9c start + 52
)
terminate called after throwing an instance of 'NSException’
zsh: abort ./test_sdl

(Note that I have no idea what libsdlmain is, I only ever linked against
libsdl on Linux)
Seems to be an OSx specific thing.On Sat, Dec 11, 2010 at 1:52 PM, Zolt?n K?csi wrote:

Regards,

Zoltan


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m trying to run a simple SDL test under OSX 10.6 but it fails, saying:

int main(int argc, char *argv[]) {
run();
}

#include <SDL/SDL.h>

I think the problem is that main is declared before SDL.h is included, you
should include SDL before main so that SDL substitutes main() with
SDL_main() and does it’s internal initializations. You should also link with
SDLmain.On Wed, Dec 8, 2010 at 12:09 PM, Lagrange Marc wrote:


Ing. Gabriele Greco, DARTS Engineering
Tel: +39-0105761240 Fax: +39-0105760224
s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY)

(Note that I have no idea what libsdlmain is, I only ever linked against
libsdl on Linux)

Regards,

Zoltan


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

sdl-config --cflags --libs is the recommended way, atleast on GCC.
Everyone loves a good one liner, especially if it works the same on
all systems.
SDL makes it so easy, programmers don’t even have to worry about cc parameters.On Sat, Dec 11, 2010 at 7:52 AM, Zolt?n K?csi wrote: