# Solved: Dev-C++ Linker Error



## lotuseclat79 (Sep 12, 2003)

Which library does a Dev-C++ compiled program have to link with to resolve the following [Linker error]: 
undefined reference to '[email protected]' 
ld returned 1 exit status
when WinMain is clearly defined in the C++ source code as the name of main, using the Dev-C++ environment v4.9.9.2. and #include <windows.h>, i.e.:

#include <windows.h>
...
void WinMain()
{
...
}

On Unix I used to run a piped command like:
cat lib*.a | ??? | gawk 'WinMain'
well, maybe I ran a script that fed the list of libraries in one at a time to the middle command or something like that, in order to find an interface like 'WinMain' in a library, but do not see anyway of doing the same on WinXP hosting the Dev-C++ environment.

Also, obviously, I've been away from Unix too long to remember the middle command. Duh?

-- Tom


----------



## lotuseclat79 (Sep 12, 2003)

Found this answer at:
http://www.libsdl.org/faq.php?action=listentries&category=4#58
Q:	I get "Undefined reference to '[email protected]'"
A:	Under Visual C++, you need to link with SDLmain.lib. Under the gcc build environments including Dev-C++, you need to link with the output of "sdl-config --libs", which is usually: -lmingw32 -lSDLmain -lSDL -mwindows

Well, it looks like I'm not using the SDL stuff that I would have to download from here to implement that solution:
http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut1
so, for now I'm just going to keep slogging away until someone replies to this thread other than me.

-- Tom


----------



## lotuseclat79 (Sep 12, 2003)

Here is what resolved this problem, as per part of the FAQ at Dev-C++ website:
void WinMain () "changed to" int main()
allowed the compilation to complete and create main.o. Note: if you only change WinMain to main and keep the void, likely your compilation will continue to fail.

Also, had to disable HIPS (Prevx1R) to prevent ld.exe from being blocked - guess the HIPS seems to be working! :up:

-- Tom


----------

