SDL newbie (SDLmain doesn't work either)

Hi Pete, thanks for your suggestion. I already thought that this is the
purpose of SDL_main. But additionally linking with -lsdlmain doesn’t work!
(ie. it keeps complaining about a missing WinMain at 16)

Now things get a bit funny: I downloaded the complete source of SDL 1.2.

If I manually create a command line for gcc, that contain all object files
of SDL explicitely (including win32/SDL_main.o), then I can compile and run
the test programs. It looks like this:

gcc -o testsprite.exe testsprite.o SDL.o SDL_video.o SDL_dx5video.o …
… …

But if I create a static library from exactly the same object files with the
ar command

ar rs libsdl.a SDL.o SDL_video.o SDL_dx5video.o … … …

and link against this library

gcc -o testsprite.exe testsprite.o -lsdl

it says: “unresolved WinMain at 16”.
Listing the contents of “libsdl.a” with the “nm” command actually shows a
WinMain entry:

SDL_main.o:
(…)
00000368 T WinMain at 16

Has anyone experiences how to get this right?

Christian Sch?ler writes:

But if I create a static library from exactly the same object files with the
ar command

ar rs libsdl.a SDL.o SDL_video.o SDL_dx5video.o … … …

and link against this library

gcc -o testsprite.exe testsprite.o -lsdl

it says: “unresolved WinMain at 16”.

An off-chance possibility… Try running ranlib on that library:

    ranlib libsdl.a

and then try linking. If you are in an environment that requires
ranlib, then the table of contents created by ranlib is needed to
resolve some dependencies within the library if the object files
aren’t inserted into the library in exactly the correct order. Most
environment that require ranlib generate makefiles that automatically
call it after appending an object file to a library. This may not
have occured automagically in your environment for some reason.

Derrell

It sounds like you are using either cygwin or mingw32…

if you use mingw32 you need to link with the libmingw32.a (or with the
cygwin library, if you use cygwin) before (!!!) you link libSDLmain and
libSDL (best is to use this order…)

Regards,

Sascha

-----Urspr?ngliche Nachricht-----Von: owner-sdl at lokigames.com [mailto:owner-sdl at lokigames.com]Im Auftrag
von Christian Sch?ler
Gesendet: Mittwoch, 28. M?rz 2001 03:11
An: sdl at lokigames.com
Betreff: [SDL] Re: SDL newbie (SDLmain doesn’t work either)

Hi Pete, thanks for your suggestion. I already thought that this is the
purpose of SDL_main. But additionally linking with -lsdlmain doesn’t work!
(ie. it keeps complaining about a missing WinMain at 16)

Now things get a bit funny: I downloaded the complete source of SDL 1.2.

If I manually create a command line for gcc, that contain all object files
of SDL explicitely (including win32/SDL_main.o), then I can compile and run
the test programs. It looks like this:

gcc -o testsprite.exe testsprite.o SDL.o SDL_video.o SDL_dx5video.o …
… …

But if I create a static library from exactly the same object files with the
ar command

ar rs libsdl.a SDL.o SDL_video.o SDL_dx5video.o … … …

and link against this library

gcc -o testsprite.exe testsprite.o -lsdl

it says: “unresolved WinMain at 16”.
Listing the contents of “libsdl.a” with the “nm” command actually shows a
WinMain entry:

SDL_main.o:
(…)
00000368 T WinMain at 16

Has anyone experiences how to get this right?