Undefined Symbol _main on OSX

Hello,

I’ve got a strange problem with SDL 1.2.8 on Mac OS X 10.3.9.
I wrote a little program that only contains a main function that
returns immediately. As soon as I include SDL/SDL.h I cannot compile
the program anymore. The linker complains about an undefined symbol
_main. I use the following command to compile my program:
gcc sdl.c -framework SDL -framework COCOA

Does anyone know how to fix this issue? Thanks in advance!

Michael

Quoth Michael Gruetzner <Michael_Gruetzner at gmx.de>, on 2005-04-30 19:35:13 +0200:

I use the following command to compile my program:
gcc sdl.c -framework SDL -framework COCOA

Do not do that directly. Use sdl-config --cflags --libs instead, to
substitute the output of sdl-config.

http://www.libsdl.org/cgi/docwiki.cgi/FAQ_20Compiling_20on_20Linux has
information about this in the section “Compiling … using GCC”.

(I should probably factor the GCC stuff out onto a separate page,
but I’m not sure what the situation is on OS X exactly still…)

—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050430/1eb50ee9/attachment.pgp

Quoth Michael Gruetzner <Michael_Gruetzner at gmx.de>, on 2005-04-30 19:35:13 +0200:

I use the following command to compile my program:
gcc sdl.c -framework SDL -framework COCOA

Do not do that directly. Use sdl-config --cflags --libs instead, to
substitute the output of sdl-config.

Actually, there is no sdl-config provided with the framework version
of SDL so that won’t work.

You need to include the SDLmain.h and SDLmain.m files directly in your
project so they are compiled with it. You can find these with the
SDL-devel.pkg on the website. After you install it, start Xcode and
select the create a new SDL application project template. It will
create a simple SDL project for you. Inside you will see that it
copied SDLmain.* into you project. You can modify this project for
your needs or just copy out the SDLmain files into your own project.
(Alternatively, you can search for SDLmain on your system and just add
those files yourself without going through Xcode. If you have
Spotlight, this will be quick :slight_smile:

Also, it’s -framework Cocoa and not -framework COCOA (though you might
be able to get away with that since the default filesystem on OS X is
case insensitive).

You should check out the Mac OS X FAQ on the SDL FAQ page:
http://www.libsdl.org/faq.php

-Eric> From: Drake Wilson

I’ve got a strange problem with SDL 1.2.8 on Mac
OS X 10.3.9. I wrote a little program that only
contains a main function that returns immediately.
As soon as I include SDL/SDL.h I cannot compile
the program anymore. The linker complains about
an undefined symbol _main. I use the following
command to compile my program:
gcc sdl.c -framework SDL -framework COCOA

Someone has already mentioned that you need to use the output of
’sdl-config --cflags --libs’ in your gcc command line, however since
you are using the framework version of SDL (which is the proper way
in OS X, in my humble opinion) you probably don’t have an sdl-config
script.

The easiest way to deal with this is to develop your project using
XCode. Once you install the SDL-devel package, you should have a
number of SDL project types to choose from when you create a new
project in XCode. It should set up all the compilation requirements
for you automatically.

If you really need to use the command line, however, you’ll need to
create your own ‘sdl-config’ script. I wrote a quick version for this
situation, which I keep in ~/bin. For ‘sdl-config --cflags’ it
outputs:

-F/Users/yourname/Library/Frameworks
-I/Users/yourname/Library/Frameworks/SDL.framework/Headers
-D_REENTRANT

For ‘sdl-config --libs’ it outputs:

/Users/yourname/bin/SDLMain.o -L/Users/yourname/Library/Frameworks
-framework Cocoa -framework SDL -lobjc

(Both of these outputs are only one line… and you should adjust them
according to where you installed the SDL framework.)

Finally, you’ll notice the SDLMain.o in the --libs output above. I
keep it pre-compiled for simplicity. You just need to grab SDLMain.m,
which is included in the developer stationary that comes with the
SDL-devel package. There are a few versions, use the one from the
"SDL Application" project stationary. Compile it with

gcc /path/to/sdl-config --cflags -c SDLMain.m

to produce the .o file. Everything should work after that.__
Steve Saunders

Find local movie times and trailers on Yahoo! Movies.

Hello,

thank you for that hint. I use sdl-config now and everything works fine
:).

MfG
MichaelOn Sat, Apr 30, 2005 at 02:46:55PM -0400, Drake Wilson wrote:

Quoth Michael Gruetzner <Michael_Gruetzner at gmx.de>, on 2005-04-30 19:35:13 +0200:

I use the following command to compile my program:
gcc sdl.c -framework SDL -framework COCOA

Do not do that directly. Use sdl-config --cflags --libs instead, to
substitute the output of sdl-config.

http://www.libsdl.org/cgi/docwiki.cgi/FAQ_20Compiling_20on_20Linux has
information about this in the section “Compiling … using GCC”.

(I should probably factor the GCC stuff out onto a separate page,
but I’m not sure what the situation is on OS X exactly still…)

—> Drake Wilson


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


dprintk(“kick_rx: maybe kicking\n”);
linux-2.6.6/drivers/net/ns83820.c