Undefined reference to _SDL_main

I have been trying for weeks to compile something, anything with SDL using the LCC-WIN32 compiler. All of the instructions I found on the internet for setting it up for SDL are outdated… Nevertheless I think I found all of the correct ways to configure it… Unfortunately, even the smallest test program leaves me with the Undefined reference to _SDL_main

Just to go over a few things that most people will probably assume I did wrong… the first part of the code looks like this:

Code:

#include “SDL.h”

int main( int argc, char* argv[] )
{
/* initialize SDL */
SDL_Init(SDL_INIT_VIDEO);

/* set the title bar */
SDL_WM_SetCaption("SDL Test", "SDL Test");

So all of that should be correct. I added C:\SDL-1.2.14\include into the “include path” area under the compiler settings. (yes, that is the correct path on my hard drive) and I’ve added sdl.lib to the “additional files to be included in the link.” Also I have also told it to “import foreign library” and successfully imported the sdl.lib file.

Any ideas? Anyone out there using LCC-Win32 with SDL library? I’m also using Windows 7 but I seriously doubt that is the issue. please help!

I’m not familiar with that compiler. Is there a reason you are not using mingw (GCC)?

TheBuzzSaw wrote:

I’m not familiar with that compiler. Is there a reason you are not using mingw (GCC)?

I supposed because I’m unfamiliar with it. The only two decent compilers I was aware of on Windows was Microsoft’s Visual Studio (which I don’t want to use or pay for) and LCC-Win32. But, I’ll go check out this other compiler you mention. I’m guessing I can find information on how to get SDL working with it?

If you’re getting an undefined reference, that means that the linker could
not find the definition for a particular function. This one is found in
SDLmain.lib (or similar). Try adding that to “additional files to be
included in the link” before SDL.lib.

Jonny DOn Wed, Dec 2, 2009 at 8:59 AM, adric22 wrote:

TheBuzzSaw wrote:

I’m not familiar with that compiler. Is there a reason you are not using
mingw (GCC)?

I supposed because I’m unfamiliar with it. The only two decent compilers I
was aware of on Windows was Microsoft’s Visual Studio (which I don’t want to
use or pay for) and LCC-Win32. But, I’ll go check out this other compiler
you mention. I’m guessing I can find information on how to get SDL working
with it?


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

[quote=“Jonny D”]If you’re getting an undefined reference, that means that the linker could not find the definition for a particular function. ?This one is found in SDLmain.lib (or similar). ?Try adding that to?“additional files to be included in the link” before SDL.lib.

Okay, I tried that with LCC-Win32. I got a different error this time. Now I get:

Code:
Wedit output window build: Wed Dec 02 12:44:42 2009
: multiple definition of _WinMain at 16
first definition is in file sdl_win32_main.obj
537.obj: multiple definition of _fprintf
first definition is in file xprintf.obj
Error c:\sdl-1.2.14\src\main\win32\sdl_win32_main.c 315 undefined reference to _SDL_main
.text: undefined reference to '__alloca_probe’
c:\lcc\bin\make.exe
Compilation + link time:0.0 sec, Return code: 5