title: Error creating a window in windows "undefined reference to 'WinMain@16'"
body: <pre><code>#ifndef UNICODE
  #define UNICODE
  #endif
  
  #include &lt;windows.h&gt;
  
  LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  
  int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int     nCmdShow)
  {
  
  const wchar_t CLASS_NAME[]  = L"Sample Window Class";
  
  WNDCLASS wc = { };
  
  wc.lpfnWndProc   = WindowProc;
  wc.hInstance     = hInstance;
  wc.lpszClassName = CLASS_NAME;
  
  RegisterClass(&amp;wc);
  
  
  
  HWND hwnd = CreateWindowEx(
      0,
      CLASS_NAME,
      L"Learn to Program Windows",
      WS_OVERLAPPEDWINDOW,
  
  
      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  
      NULL,
      NULL,
      hInstance,
      NULL
      );
  
  if (hwnd == NULL)
  {
      return 0;
  }
  
  ShowWindow(hwnd, nCmdShow);
  
  
  
  MSG msg = { };
  while (GetMessage(&amp;msg, NULL, 0, 0))
  {
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
  }
  
  return 0;
  }
  LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  {
      switch (uMsg)
      {
      case WM_DESTROY:
      PostQuitMessage(0);
      return 0;
  
  case WM_PAINT:
      {
          PAINTSTRUCT ps;
          HDC hdc = BeginPaint(hwnd, &amp;ps);
  
          FillRect(hdc, &amp;ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
  
          EndPaint(hwnd, &amp;ps);
      }
      return 0;
  
  }
  return DefWindowProc(hwnd, uMsg, wParam, lParam);
  }
  </code></pre>
  
  <p>This is the code, which is also the standard example you can find in the microsoft website that teach people how to program windows.
  <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff381409(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/ff381409(v=vs.85).aspx</a></p>
  
  <p>The problem I receive is the following whenever I try to compile this code in codeblocks.</p>
  
  <p>undefined reference to 'WinMain@16'</p>
  
  <p>What is that and what can I do to compile and run this piece of code?</p>