Question on SDL on mingw32

Hi All,

I’m new to SDL. Coded a audio waveform generator using SDL on Debian 3.1r4
successfully on an i386 platform. Now attempting to port to Win2k using MinGW
without success. Need some guidance but I am not sure whether this is the
correct place I should post this question. If it isn’t, hope somebody could
guide me in some direction. If it is, could somebody help with the following?

COMPILE-------
$ gcc -I/local/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -lmingw32 -L/local/l
ib -lSDLmain -lSDL -mwindows SDL_wave4.c -o SDL_wave4

Below are the error messages returned. The first 2 warnings are okay.
Subsequent errors are one that I’ve been trying to get rid. I suspect I might
have set up MinGW/MSys wrongly but just could not find the problem. My code
called SDL_Init but no error was reported, and therefore I presume no problem
with locations of the *.a lib files.

SDL_wave4.c: In function waveCommit': SDL_wave4.c:139: warning: initialization makes integer from pointer without a cast C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xba0): undefined reference toSDL_OpenAudio’
C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xbf8):
undefined reference to SDL_PauseAudio' C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xbfd): undefined reference toSDL_GetAudioStatus’
C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xc12):
undefined reference to SDL_Delay' C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xc34): undefined reference toSDL_Delay’
C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xc58):
undefined reference to SDL_Delay' C:/DOCUME~1/library3/LOCALS~1/Temp/ccgdcaaa.o:SDL_wave4.c:(.text+0xce2): undefined reference toSDL_CloseAudio’
collect2: ld returned 1 exit status

INSTALL MinGW/MSys/SDL

I used MinGW-5.1.3.exe to install MinGW in C:\MinGW.
I used MSYS-1.0.10.exe to install MSys in C:\Msys. (A final hiccup was that
Msys.ini wasn’t installed as I’m not the administrator of the computer, is
this okay?)
I used SDL-1.2.11.zip to “configure”, “make” and “make install” in an MSys
rxvt terminal.

I’ll be glad to provide more information …

Thanks in advance!

Best regards,
ping-lek
P.S. One quick question (perhaps obvious …), how can I open and write to 8-
channel audio (aka HD Audio) “simultaneously” using SDL?

COMPILE

$ gcc -I/local/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -lmingw32 -L/local/l
ib -lSDLmain -lSDL -mwindows SDL_wave4.c -o SDL_wave4

Hey, I added this to the FAQ:
http://www.libsdl.org/faq.php?action=listentries&category=4#88

When you’re compiling with gcc, you need to make sure the output of sdl-config follows your source file on the command line:
gcc -o test test.c sdl-config --cflags --libs

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

Sam Lantinga <slouken devolution.com> writes:

COMPILE

$ gcc -I/local/include/SDL -D_GNU_SOURCE=1 -Dmain=SDL_main -lmingw32 -
L/local/l

ib -lSDLmain -lSDL -mwindows SDL_wave4.c -o SDL_wave4

Hey, I added this to the FAQ:
http://www.libsdl.org/faq.php?action=listentries&category=4#88

When you’re compiling with gcc, you need to make sure the output of sdl-
config follows your source file on
the command line:
gcc -o test test.c sdl-config --cflags --libs

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

Sam,

Thanks for your information, I tried it earlier and it worked. Went ahead and
found that if I had given the source file and the output file as the first 2
arguments for gcc, I wouldn’t have the problem:

$ gcc SDL_wave4.c -o SDL_wave4 -I/local/include/SDL -D_GNU_SOURCE=1 -
Dmain=SDL_main -lmingw32 -L/local/lib -lSDLmain -lSDL -mwindows

I’m pretty new to gcc … and the “gcc --help” indicated “gcc
files”, which made me presume that all input files should be given as last
argument. (But why this doesn’t happen in my Linux box? Hmmm …)

Thanks again!
ping-lek