Search code examples
c++winapivisual-studio-2012linkerstatic-linking

Win32 Application LNK2001: unresolved external symbol _main


I have been trying to make a WIN32 Application with a GUI (NOT a simple console application) on VS2012, and I'm stuck with this one error. My project is on Release configuration. My main function looks like this:

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{

    return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);
}

What I've tried:

1) Creating a new WIN32 Project with these settings:

  • Application Type -> Windows application
  • Additional options -> Empty Project (With NO SDL!)
  • No other options checked

2) Changing between Unicode and Multi-Byte Character Sets

3) Changing the SubSystem (from Windows (/SUBSYSTEM:WINDOWS) to Not Set)

4) Adding entry points (main ; _main ; WinMain)

5) Adding #undef _ATL_MIN_CRT (I'm pretty sure it was disabled anyway, but still did it for extra insurance...)

NONE of these solved my issue. I've searched the Internet and haven't found anyone with a similar problem (creating a WIN32 Application) who has solved their issue.

EDIT: I'm also using Allegro 5 library and I'm building the program with /MT .

Any recommendations are welcome.


Solution

  • After some searching I've found the answer.

    All I needed to do was to define ALLEGRO_NO_MAGIC_MAIN .