undefined reference to `_alloca_probe’I hopes to alienate and contradict more people on this list, I’ll take Niel as my target today.
You need to do two things to avoid the multible-main-definition thing:
1. Add the flag “-Dmain=SDL_main” to your compile.
2. #include <SDL_main.h>
I don’t think I’ve ever tried compiling without both, so I’m not sure if the second is actually nessecary (The #include actually #define’s main to SDL_main, but the #include is mandatory for SDL_RegisterApp() on Win32)
As for the others, I’m not 100% sure if this is where it’s at, but try adding “-lwinmm” (fairly sure that’s where alloca_probe() is)
Question: Are you using the VC6 binaries, or did you compile from source? If you’re using the source, you can probably get more out of MinGW if you compile your programs from MSYS [Silicon’s recommended download to any MinGW user] using some sort of makefile. Yes, even if it’s only one source file – someday it might be two (that, and it keeps the carpel tunnel away by making you type less when debugging your source). Or, at the very least, using the output of sdl-config --cflags
and sdl-config --libs
when choosing the flags to compile with.
p.s. Trying to suggest Makefile Voodoo atleast once every week makes me feel all warm inside.
p.s.s. Silicon does not provide warranty, explicitly or implied, to use of Makefile Voodoo. Your head size may varry.
p.s.s.s. Warm fuzzy feeling may or may not be burritos.----- Original Message -----
From: Gus Tenrreiro
To: sdl at libsdl.org
Sent: Friday, December 12, 2003 1:23 PM
Subject: [SDL] undefined reference to `_alloca_probe’
I am trying to compile the following program:
#include <stdio.h>
#include <SDL.h>
int main(int argc, char *argv[])
{
int i;
/* Initialize SDL first */
if ( SDL_Init(SDL_INIT_CDROM) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
/* Find out how many CD-ROM drives are connected to the system */
printf("Drives available: %d\n", SDL_CDNumDrives());
for ( i=0; i<SDL_CDNumDrives(); ++i ) {
printf("Drive %d: \"%s\"\n", i, SDL_CDName(i));
}
}
I compile using the following line:
gcc -I C:/SDL-LIB/SDL-1.2.6/include -LC:/SDL-LIB/SDL-1.2.6/lib/ -lmingw32 -lSDLmain -lSDL -mwindows -o listCDRoms listCDRoms.c
but I get the following error message:
C:/SDL-LIB/SDL-1.2.6/lib/\SDLmain.lib(./Release/SDL_main.obj)(.text+0x0):C:\SDL-1.2\Src\Mai: multiple definition of `main’
c://MinGW//bin/…/lib/gcc-lib/mingw32/3.2.3/…/…/…/libmingw32.a(main.o)(.text+0x0):main.c: first defined here
Warning: .drectve %.*s' unrecognized Warning: .drectve
%.*s’ unrecognized
Warning: .drectve %.*s' unrecognized Warning: .drectve
%.*s’ unrecognized
C:/SDL-LIB/SDL-1.2.6/lib/\SDLmain.lib(./Release/SDL_main.obj.b)(.text+0x55):C:\SDL-1.2\Src\Mai: undefined reference to `_alloca_probe’
C:/SDL-LIB/SDL-1.2.6/lib/\SDLmain.lib(./Release/SDL_main.obj.b)(.text+0x16f):C:\SDL-1.2\Src\Mai: undefined reference to `_alloca_probe’
C:/SDL-LIB/SDL-1.2.6/lib/\SDLmain.lib(./Release/SDL_main.obj.b)(.text+0x1c0):C:\SDL-1.2\Src\Mai: undefined reference to `_alloca_probe’
I am using MingW 3.1.0
and SDL devel 1.2.6 VC6 (but I use mingw to compile)
Thanks
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.547 / Virus Database: 340 - Release Date: 12/2/2003