Help, "multiple definitions of _atexit"

Guys,

I can develop apps including SDL and compile them fine so long as I don’t
include “stdlib.h” and link it with -lc. But I want to use “random()”, and
every time I try the linker gives me the error message “multiple definitions
of _atexit”.

I am running cygwin on top of Windows XP and using gcc to compile it.
Everything works if I don’t link -lm. I already tried multiple versions of
gcc, cygwin, and nothing seems to work. I’m stuck.

Has anyone seen this before? I am in a bad need of some help…

Thanks,

Bernardo.

I don’t know if the SDL mingw files are meant to be used with cygwin or not.

Sorry that I can’t offer much help on this.

Bernardo wrote:> Guys,

I can develop apps including SDL and compile them fine so long as I don’t
include “stdlib.h” and link it with -lc. But I want to use “random()”, and
every time I try the linker gives me the error message “multiple definitions
of _atexit”.

I am running cygwin on top of Windows XP and using gcc to compile it.
Everything works if I don’t link -lm. I already tried multiple versions of
gcc, cygwin, and nothing seems to work. I’m stuck.

Has anyone seen this before? I am in a bad need of some help…

Thanks,

Bernardo.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Forest ‘LordHavoc’ Hale
Author of DarkPlaces Quake1 engine and mod
http://icculus.org/twilight/darkplaces/
Address: 94340 Horton Road Blachly OR 97412
Phone/Fax: 541-925-4130

You may need to re-order your library dependencies.

For a mingw project I’m working on, I use:
LIBS = -L$(LIBDIR) -mwindows -lws2_32 -lmingw32 lib\SDL_image.dll
lib\libSDL.dll.a lib\libSDLmain.a -lopengl32 -lglu32 -lm

Notice that -lm is last in the list. I seem to recall that the order
mattered, and this was the order I ended up. -lm may define _atexit,
which libSDLmain redefines, so that is bad. But, if -lm is last, it
may check to see if _atexit is defined before defining it.

Hope this helps,

JohnOn Mon, Nov 17, 2008 at 2:00 PM, Forest Hale wrote:

I don’t know if the SDL mingw files are meant to be used with cygwin or not.

Sorry that I can’t offer much help on this.

Bernardo wrote:

Guys,

I can develop apps including SDL and compile them fine so long as I don’t
include “stdlib.h” and link it with -lc. But I want to use “random()”, and
every time I try the linker gives me the error message “multiple definitions
of _atexit”.

I am running cygwin on top of Windows XP and using gcc to compile it.
Everything works if I don’t link -lm. I already tried multiple versions of
gcc, cygwin, and nothing seems to work. I’m stuck.

Has anyone seen this before? I am in a bad need of some help…

Thanks,

Bernardo.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Forest ‘LordHavoc’ Hale
Author of DarkPlaces Quake1 engine and mod
http://icculus.org/twilight/darkplaces/
Address: 94340 Horton Road Blachly OR 97412
Phone/Fax: 541-925-4130


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org