title: What does this MSVC++ compile error mean
body: <p>I have this compile error that I dont understand what is wrong. My Microsoft Visual Studio project is a Win32 Project (not console):</p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>1&gt;MSVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
  1&gt;C:\Users\Soribo\Desktop\C++ Programming\Visual C++ Programming\KeyboardHook\Release\KeyboardHook.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <p><strong>EDIT: After making #include "stdafx.h" as the 1st line the compile error is:</strong></p>
  
  
  
  <pre class="lang-none prettyprint-override"><code>1&gt;MSVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
  1&gt;C:\Users\Soribo\Desktop\C++ Programming\Visual C++ Programming\KeyboardHook\Release\KeyboardHook.exe : fatal error LNK1120: 1 unresolved externals
  </code></pre>
  
  <p><strong>EDIT: hmm, I have defined WinMain function haven't I? see below code:</strong></p>
  
  <pre><code>/*
    Application: 
  */
  
  #include &lt;windows.h&gt;
  #include &lt;cstdlib&gt;
  #include "stdafx.h"
  
  using namespace std;
  
  static HHOOK     keyboardHook;
  static HINSTANCE gInstance;
  
  
  // Functions List //
  LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam );
  HHook ActivateKeyboardHook( HookProc hookProc, HINSTANCE hInstance );
  bool DeactivateKeyboardHook( HHook keyboardHook );
  
  
  int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
  //int WINAPI WinMain( HINSTANCE gInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
  {
      WNDCLASSEX wc;
      HWND hwnd;
      MSG Msg;
  
      //Step 1: Registering the Window Class
      wc.cbSize        = sizeof(WNDCLASSEX);
      wc.style         = 0;
      wc.lpfnWndProc   = WndProc;
      wc.cbClsExtra    = 0;
      wc.cbWndExtra    = 0;
      wc.hInstance     = gInstance;
      wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
      wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
      wc.hbrBackground = (HBRUSH)(DKGRAY_BRUSH);
      wc.lpszMenuName  = NULL;
      wc.lpszClassName = L"Custom Class";
      wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
  
      // if registration of main class fails
      if(!RegisterClassEx(&amp;wc))
      {
          MessageBox(NULL, L"Window Registration Failed!", L"Error!",
              MB_ICONEXCLAMATION | MB_OK);
          return 0;
      }
  
      // Step 2: Creating the Window
      hwnd = CreateWindowEx(
          WS_EX_CLIENTEDGE,
          L"Custom Class",
          L"App Name",
          WS_CAPTION|WS_MINIMIZEBOX|WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU,
          CW_USEDEFAULT, CW_USEDEFAULT, 600, 500,
          NULL, NULL, gInstance, NULL);
  
      if(hwnd == NULL)
      {
          MessageBox(NULL, L"Window Creation Failed!", L"Error!",
              MB_ICONEXCLAMATION | MB_OK);
          return 0;
      }
  
      ShowWindow(hwnd, nCmdShow);
      UpdateWindow(hwnd);
  
      // Step 3: The Message Loop
      while(GetMessage(&amp;Msg, NULL, 0, 0) &gt; 0)
      {
          TranslateMessage(&amp;Msg);
          DispatchMessage(&amp;Msg);
      }
      return Msg.wParam;
  }
  
  LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )
  {
      /*if ( code &lt; 0 )
      {
          return CallNextHookEx( NULL, code, wParam, lParam );
      }*/  
  
      switch ( wParam )
      {
          case WM_KEYDOWN:
          {
              MessageBox( NULL, L"Notify", L"Key Down", MB_OK );        
          }
          break;
          case WM_KEYUP:
          {
              MessageBox( NULL, L"Notify", L"Key Up", MB_OK );                        
          }
          break;
          case WM_SYSKEYDOWN:
          {
              MessageBox( NULL, L"Notify", L"Sys Key Down", MB_OK );                        
          }
          break;
          case WM_SYSKEYUP:
          {
              MessageBox( NULL, L"Notify", L"Sys Key Up", MB_OK );                        
          }
          break;
          default:
          {
          } 
          break;
      }
  
      return CallNextHookEx( NULL, nCode, wParam, lParam );
  }
  
  LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
  
      switch(msg)
      {
          case WM_CREATE:
          {                  
               keyboardHook = ActivateKeyboardHook( &amp;LowLevelKeyboardProc, gInstance );
          }    
          break;
          case WM_COMMAND:
          {
               switch(LOWORD(wParam)) 
               {
  
                    default:
                    break;
               }
          }
          break;
          case WM_CLOSE:
          {
              DeactivateKeyboardHook( keyboardHook );
              DestroyWindow(hwnd);
          }
          break;
          case WM_DESTROY:
              PostQuitMessage(0);
          break;
          default: 
          break;
      }
  
      return DefWindowProc(hwnd, msg, wParam, lParam);
  }
  
  HHOOK ActivateKeyboardHook( HookProc hookProc, HINSTANCE hInstance )
  {
       return SetWindowsHookEx( WH_KEYBOARD_LL, hookProc, hInstance, 0 );
  }
  
  bool DeactivateKeyboardHook( HHook keyboardHook )
  {
       return UnhookWindowsHookEx( keyboardHook );
  }
  </code></pre>