Undefined reference to 'SDL_main'

What causes the error undefined reference to ‘SDL_main’? I use mingw32
with windows 2000. I have sdl 1.2.4 and I have another project which
compiles just fine. Then I tried to create a simplier sdl-library test,
and it gives the following:

…libSDLmain.a(SDL_main.o.b): In function ‘console_main’:
//c/tmp/sdl-1.2.4/src/main/SDL_main.c:227: undefined reference to ‘SDL_main’

I compile it with

gcc test.o -otest.exe -lmingw32 -lSDLmain -mwindows -lSDL -lSDL_image
-lglu32 -lopengl32 -lstdc++

These are the exactly same parameters as in the other project which
compiles with no problems. What could cause this?

Thank you!

I belive that the problem is use c++ with sdl.
I’ve very much problems mixing c++ and c with cygwin.

El vie, 24-05-2002 a las 21:39, Juhana Lehtiniemi escribi?:

What causes the error undefined reference to ‘SDL_main’? I use mingw32
with windows 2000. I have sdl 1.2.4 and I have another project which
compiles just fine. Then I tried to create a simplier sdl-library test,
and it gives the following:

…libSDLmain.a(SDL_main.o.b): In function ‘console_main’:
//c/tmp/sdl-1.2.4/src/main/SDL_main.c:227: undefined reference to ‘SDL_main’

I compile it with

gcc test.o -otest.exe -lmingw32 -lSDLmain -mwindows -lSDL -lSDL_image
-lglu32 -lopengl32 -lstdc++
Another question… Not is g++ instead gcc?>
These are the exactly same parameters as in the other project which
compiles with no problems. What could cause this?

Thank you!


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

Read the FAQ:

http://www.libsdl.org/faq.php?action=listentries&category=4#48

When you compile test.{cc,cpp,cxx,C}, you pass it the -Dmain=SDL_main
option.

-MarkOn Fri, 24 May 2002, Juhana Lehtiniemi wrote:

What causes the error undefined reference to ‘SDL_main’? I use mingw32
with windows 2000. I have sdl 1.2.4 and I have another project which
compiles just fine. Then I tried to create a simplier sdl-library test,
and it gives the following:

…libSDLmain.a(SDL_main.o.b): In function ‘console_main’:
//c/tmp/sdl-1.2.4/src/main/SDL_main.c:227: undefined reference to ‘SDL_main’

I compile it with

gcc test.o -otest.exe -lmingw32 -lSDLmain -mwindows -lSDL -lSDL_image
-lglu32 -lopengl32 -lstdc++

These are the exactly same parameters as in the other project which
compiles with no problems. What could cause this?

Thank you!


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


Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.

Or you just use SDL_main instead of main and always link SDLmain in. This
seems the best option all around, IMO.On Fri, May 24, 2002 at 01:18:43PM -0700, Mark K. Kim wrote:

When you compile test.{cc,cpp,cxx,C}, you pass it the -Dmain=SDL_main
option.


Joseph Carter Sooner or later, BOOM!

“Lord grant me the serenity to accept the things I cannot
change, the courage to change the things I can, and the wisdom
to hide the bodies of the people I had to kill because they
pissed me off.”

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020524/53efdff2/attachment.pgp

What causes the error undefined reference to ‘SDL_main’? I use mingw32
with windows 2000. I have sdl 1.2.4 and I have another project which
compiles just fine. Then I tried to create a simplier sdl-library test,
and it gives the following:

…libSDLmain.a(SDL_main.o.b): In function ‘console_main’:
//c/tmp/sdl-1.2.4/src/main/SDL_main.c:227: undefined reference to
’SDL_main’

I compile it with

gcc test.o -otest.exe -lmingw32 -lSDLmain -mwindows -lSDL -lSDL_image
-lglu32 -lopengl32 -lstdc++

These are the exactly same parameters as in the other project which
compiles with no problems. What could cause this?

Thank you!

Remove the -lSDLmain and see what happens. I dont use minigw32, but I do use
GCC under Linux, and I never link with SDLmain. I may be wrong.

Mike S. Codename: Freak901010>From: Juhana Lehtiniemi

Reply-To: sdl at libsdl.org
To: sdl at libsdl.org
Subject: [SDL] undefined reference to 'SDL_main’
Date: Fri, 24 May 2002 22:39:21 +0300 (EET DST)


Chat with friends online, try MSN Messenger: http://messenger.msn.com

You are wrong. MingW32 works exactly the way other Win32 compilers do,
you need a WinMain.

In order to make sure things work, the file which contains your main()
must include SDL.h or SDL_main.h specifically. You need -mwindows on the
link line. sdl-config --libs should do this automatically if you’re using
it. You’ll also need to use -lSDLmain.

Alternatively (and IMO a better idea) is to always use -lSDLmain and use
SDL_main () in your code rather than main () - SDL will do the right thing
on all platforms that way.

Comparing Linux and Win32 is a bad idea, especially when talking about a
fork of gcc intended to build native Win32 code the way the Win32
compilers do it. This information is all documented on the SDL website,
under the Win32 FAQ area. It’s important reading for anyone who wants to
use code written for SDL in Win32. Actually, all of the FAQ sections are
important reading for any person working with SDL.On Fri, May 24, 2002 at 07:14:32PM -0600, mike shoup wrote:

Remove the -lSDLmain and see what happens. I dont use minigw32, but I do
use GCC under Linux, and I never link with SDLmain. I may be wrong.


Joseph Carter My opinions are always right

  • Twilight1 will have to hang his Mozilla beanie dinosaur in effigy if
    Netscape sells-out to Alot Of Losers…

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020524/b5173136/attachment.pgp