User forums > Help

SDL and Codeblocks/MinGW - WinMain undefined reference

(1/2) > >>

aboeing:
Hi,

I am trying to compile a sample SDL program, and I keep getting a:
undefined reference to `_WinMain@16'
problem.

I am using the SDL 1.2.13 mingw build from http://www.libsdl.org/download-1.2.php
SDL-devel-1.2.13-mingw32.tar.gz (Mingw32)

And a SDL sample program from here:
http://friedspace.com/SDLTest.c

This is the command line the compiler is using:
mingw32-g++.exe -LC:\lib\SDL-1.2.13\lib  -o "bin\Debug\sdl test.exe" obj\Debug\main.o    C:\lib\SDL-1.2.13\lib\libSDL.dll.a C:\lib\SDL-1.2.13\lib\libSDLmain.a

This is the output:
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

I have set the project to 'console' and set the include directory for SDL and added libSDL.dll.a and libSDLmain.a libraries.

Does anyone know how to solve the undefined reference problem?

Jenna:
Did you do a forums search ?

One Thread it gives me is: http://forums.codeblocks.org/index.php/topic,7580.0.html .

Maybe this helps.

aboeing:
Yes, I did a search and saw that topic. I've tried adding '-lmingw32 -lSDLmain -lSDL -mwindows' to the compiler options, but that did not help.

MortenMacFly:

--- Quote from: aboeing on June 16, 2009, 08:08:14 am ---Yes, I did a search and saw that topic. I've tried adding '-lmingw32 -lSDLmain -lSDL -mwindows' to the compiler options

--- End quote ---
This is not a compiler, but a linker option. Please post the full build log to see if that helps... probably a sample project would be best.

aboeing:
This is the full build log:

mingw32-g++.exe -LC:\lib\SDL-1.2.13\lib  -o "bin\Debug\sdl test.exe" obj\Debug\main.o    C:\lib\SDL-1.2.13\lib\libSDL.dll.a C:\lib\SDL-1.2.13\lib\libSDLmain.a
C:/Program Files/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

I can't attach the codeblocks project, it says the board is full.

Navigation

[0] Message Index

[#] Next page

Go to full version