Entry point problem on Mac OS X?

Hi,

I’m trying to get an SDL app running on Mac OS X. This task is made a bit
harder by the fact that I have no Mac so every time I make a change I have to
email it off to a friend who attempts to use it and emails back the error
messages. Anyway, we’ve got it as far as actually compiling, but at runtime a
whole load of errors along the lines of

2003-12-12 11:53:10.807 freqan[18105] *** _NSAutoreleaseNoPool():
Object 0x501460 of class NSCFArray autoreleased with no pool in place -
just leaking

spew out (the full list is long and basically variations on this with
different hex numbers instead of 0x501460 and different class names instead
of NSCFArray), followed by

2003-12-12 11:53:11.136 freqan[18105] *** Uncaught exception: 
<NSInternalInconsistencyException> Error (1002) creating CGSWindow
Trace/BPT trap

Um. I’m not a Mac person, I have no idea where to start fixing whatever it is
I’ve done wrong. My only clue is that it’s talking about objects and
exceptions and I’m working in pure C but SDL on Mac OS X has something to do
with Obj-C so I guess you folks might know what I’ve done wrong. The final
link command is:

gcc -W -Wall -g -O2 -Wundef -Wstrict-prototypes -Wmissing-prototypes
    -Wmissing-declarations -I/usr/local/include/SDL -D_THREAD_SAFE
    -o freqan  copy.o display.o fft.o freqan.o globals.o
    glyphs.o graphics.o main.o options.o soundcard.o version.o  
    portaudio_v18_1/pa_mac_core/libpa.a -framework CoreAudio -framework  
    AudioUnit -framework AudioToolbox -lfftw3 -lm  -lz -L/usr/local/lib  
    -lSDLmain -lSDL -framework Cocoa -framework OpenGL

although I’m not sure how relevant that is. SDL was compiled from 1.2.6 source
on that system, and we’re using Autoconf to check SDL in the manner
recommended in the docs, which is where

-I/usr/local/include/SDL -D_THREAD_SAFE

and

-L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL

come from.

Just a thought, inspired slightly by a couple of past posts: Is the entry
point wrong? None of my compilations mention Objective C at all. Does the
program just start off at int main(…) without setting up whatever a pool is
(garbage collection?) and whatever exception handling it needs? If so, what
extra options should I pass to gcc to fix it?

Many thanks,

Dave–
Dave Turner
@Dave_Turner

2003-12-12 11:53:10.807 freqan[18105] *** _NSAutoreleaseNoPool():
Object 0x501460 of class NSCFArray autoreleased with no pool in place -
just leaking

You’re right, you probably hit the wrong main(). Make sure your actual
main() function has a #include “SDL.h” above it…SDL.h will redefine it
to be SDL_Main(), and the -lSDL_main will link in the SDL’s entry point,
which calls SDL_Main() after setting up some Mac-specific stuff.

–ryan.

Aaaaah, that’s it! Thanks.

DaveOn Sunday 14 Dec 2003 1:46 am, Ryan C. Gordon wrote:

You’re right, you probably hit the wrong main(). Make sure your actual
main() function has a #include “SDL.h” above it…


Dave Turner
@Dave_Turner