Opened 7 years ago

Closed 7 years ago

#995 closed defect (fixed)

SDL on OSX, How does it work ?

Reported by: paines Owned by:
Priority: major Milestone: someday
Component: unknown Version: 4.8.x
Keywords: sdl osx Cc:
Estimated difficulty:


I compiled and installed the SDL egg using libsdl-framework via macports.
When now compiling and running a Chicken App or using csi, it will segfault with an NSInternalInconsistencyException exception.
Some sources state that SDLmain / SDL_Init must be called at first like this:
(declare (foreign-declare "#include \"SDL.h\"\n"))
(foreign-code "SDL_Init(SDL_INIT_EVERYTHING);"))
(sdl-init sdl_init_everything)))
.... more code

and then compile it with csc -feature compile-sdl file.scm under OSX, which still gives the same exception.

One more suggestion is to use the parameter
but this won't produce a working GFX context.

I am not sure if this is a real bug, or I am just not using SDL correctly under Chicken + OSX. I hope someone can clear things up.

Change History (3)

comment:1 Changed 7 years ago by paines

One thing to get things working is (at least this worked for me under OSX 10.8.2 and macports):
sudo port install xorg
sudo port install xterm
Then start Xorg via Mission Control. X icon will appear in the dock. Right click on the X and then start a Terminal.
From here you can do e.g.
SDL_VIDEODRIVER=x11 csi and develop interactively
or compile your app and start it with SDL_VIDEODRIVER=x11 ./yourBinary.

Isn't there an easier way ? The resulting binary isn't shippable or shareable among others.

comment:2 in reply to:  1 Changed 7 years ago by paines

I meant Launchpad instead of Mission Control.

comment:3 Changed 7 years ago by paines

Resolution: fixed
Status: newclosed

The solution is to Init SDL under OSX is like this:

(declare (foreign-declare "#include<SDL/SDL.h>\n"))
(foreign-code "SDL_Init(SDL_INIT_EVERYTHING);")

and compile the whole thing via
csc yourApp.scm -lSDLmain -framework Cocoa -framework Foundation

Note: See TracTickets for help on using tickets.