Code::Blocks Forums
User forums => Help => Topic started by: aboeing on June 16, 2009, 05:38:33 am
-
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?
-
Did you do a forums search (http://forums.codeblocks.org/index.php?action=search2&search=%22undefined+reference+to+%60_WinMain%4016%27%22) ?
One Thread it gives me is: http://forums.codeblocks.org/index.php/topic,7580.0.html (http://forums.codeblocks.org/index.php/topic,7580.0.html) .
Maybe this helps.
-
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.
-
Yes, I did a search and saw that topic. I've tried adding '-lmingw32 -lSDLmain -lSDL -mwindows' to the compiler options
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.
-
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.
-
I have uploaded the codeblocks project with source here:
http://www.adrianboeing.com/tmp/sdl%20test.zip
-
I have uploaded the codeblocks project with source here:
http://www.adrianboeing.com/tmp/sdl%20test.zip
Link against "mingw32" first. Next time you can try to use the wizard to create a project template for you. Cause that's what I have done and it just worked. ;-)
-
Thanks MortenMacFly! That was it, I had the dependencies in the wrong order:
for future reference this is the order you must have:
-lmingw32
-lSDLmain
-lSDL