1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Dev-C++ Linker Error

Discussion in 'Software Development' started by lotuseclat79, Apr 23, 2006.

Thread Status:
Not open for further replies.
  1. lotuseclat79

    lotuseclat79 Thread Starter

    Joined:
    Sep 12, 2003
    Messages:
    20,583
    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
     
  2. lotuseclat79

    lotuseclat79 Thread Starter

    Joined:
    Sep 12, 2003
    Messages:
    20,583
    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
     
  3. lotuseclat79

    lotuseclat79 Thread Starter

    Joined:
    Sep 12, 2003
    Messages:
    20,583
    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! (y)

    -- Tom
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/461738

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice