title: Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
body: <h2>Error:</h2>
  <pre><code>Severity Code Description Project File Line Error LNK2019 unresolved external symbol _main referenced in function &quot;int __cdecl invoke_main(void)&quot; (?invoke_main@@YAHXZ) 
  Severity    Code    Description Project File    Line
  Error   LNK1120 1 unresolved externals  
  </code></pre>
  <h2>Code:</h2>
  <pre><code>#include &quot;windows.h&quot;
  #include &quot;tchar.h&quot;
  #include &quot;d3d9.h&quot;
  #pragma comment(lib, &quot;d3d9.lib&quot;)
  
  LPDIRECT3D9 pDirect3D=NULL; 
  LPDIRECT3DDEVICE9 pDirect3DDevice=NULL; 
  const int segment = 50;
  const int NV = segment*13;
  struct CUSTOMVERTEX
  {
     float x, y, z, rhv;
     
     DWORD color;
  };
  #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
  
  LPDIRECT3DVERTEXBUFFER9 pVertexBuffer=NULL; 
  
  HRESULT InitialDirect3D(HWND hvnd)
  {
     if((pDirect3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL)
        return E_FAIL;
     D3DDISPLAYMODE Display;
  
     if(FAILED(pDirect3D-&gt;GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &amp;Display)))
        return E_FAIL;
  
     D3DPRESENT_PARAMETERS Direct3DParameter;
     ZeroMemory(&amp;Direct3DParameter, sizeof Direct3DParameter);
   
     Direct3DParameter.Windowed=TRUE;
     Direct3DParameter.SwapEffect=D3DSWAPEFFECT_DISCARD;
     Direct3DParameter.BackBufferFormat=Display.Format;
  
     if(FAILED(pDirect3D-&gt;CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hvnd,
                                       D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                       &amp;Direct3DParameter, &amp;pDirect3DDevice)))
        return E_FAIL;
     return S_OK;
  }
  HRESULT RenderingDirect3D()
  {
     if(pDirect3DDevice==NULL)
        return E_FAIL;
     pDirect3DDevice-&gt;Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(90, 150, 100), 1.f, 0);
     
     pDirect3DDevice-&gt;BeginScene();
  
     pDirect3DDevice-&gt;SetStreamSource(0, pVertexBuffer, 0, sizeof(CUSTOMVERTEX));
    
     pDirect3DDevice-&gt;SetFVF(D3DFVF_CUSTOMVERTEX);   
  
      pDirect3DDevice-&gt;DrawPrimitive(D3DPT_LINELIST, 0, NV);
      pDirect3DDevice-&gt;EndScene();
  
     pDirect3DDevice-&gt;Present(NULL, NULL, NULL, NULL);
  
     return S_OK;
  }
  
  void DeleteDirect3D()
  {
     if(pVertexBuffer)
         pVertexBuffer-&gt;Release();
     if(pDirect3DDevice)
         pDirect3DDevice-&gt;Release();
     if(pDirect3D)
         pDirect3D-&gt;Release();
  }
  
  HRESULT InitialVertexBuffer()
  {
      float u = 0.0;
      int z = 0;
      float points[][2] = {
          {150,150},
          {125,100},
          {150,50},
          {200,50},
          {225,55},
          {285,60},
          {325,25},
          
          {342,30},
          {340,35},
          {340,40},
      
          {325,75},
          {300,125},
          {300,175},
          {305,250},
          {295,287},
          {257,347},
          {200,350},
          {150,325},
          {140,290},
  
          {142,282},
          {160,280},
          {165,286},
          
          {175,325},
          {215,340},
          {250,335},
          {275,300},
          {275,250},
          {255,200},
          {250,150},
          {275,100},
          {305,65},
          
          {275,85},
          {240,95},
          {215,85},
          {170,65},
          {140,90},
          {160,135},
  
          {160,150},
          {152.5,150},
          {150,150}
      };
          
      CUSTOMVERTEX Vertexes[NV*2];
      int i = 0;
      while( i &lt; NV*2 )
      {
          u = 0.f;
          for(int j = 0; j &lt; segment; j++)
          {
              Vertexes[i].x = (1-3*u+3*u*u-u*u*u)*points[z][0]+(3*u-6*u*u+3*u*u*u)*points[z+1][0]+(3*u*u-3*u*u*u)*points[z+2][0]+(u*u*u)*points[z+3][0];
              Vertexes[i].y = (1-3*u+3*u*u-u*u*u)*points[z][1]+(3*u-6*u*u+3*u*u*u)*points[z+1][1]+(3*u*u-3*u*u*u)*points[z+2][1]+(u*u*u)*points[z+3][1];
              Vertexes[i].z = 0.5f;
              Vertexes[i].color = 0x00ffffff;
              Vertexes[i].rhv = 1.f;
              u += (float)1/segment;
              i++;
              Vertexes[i].x = (1-3*u+3*u*u-u*u*u)*points[z][0]+(3*u-6*u*u+3*u*u*u)*points[z+1][0]+(3*u*u-3*u*u*u)*points[z+2][0]+(u*u*u)*points[z+3][0];
              Vertexes[i].y = (1-3*u+3*u*u-u*u*u)*points[z][1]+(3*u-6*u*u+3*u*u*u)*points[z+1][1]+(3*u*u-3*u*u*u)*points[z+2][1]+(u*u*u)*points[z+3][1];
              Vertexes[i].z = 0.5f;
              Vertexes[i].color = 0x00ffffff;
              Vertexes[i].rhv = 1.f;
              i++;
          }
          z += 3;
      }
          if(FAILED(pDirect3DDevice-&gt;CreateVertexBuffer(NV*2*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX,
          D3DPOOL_DEFAULT, &amp;pVertexBuffer, NULL)))
              return E_FAIL;
     
     void *pVB=NULL;
     if(FAILED(pVertexBuffer-&gt;Lock(0, sizeof Vertexes, (void**)&amp;pVB, 0)))
        return E_FAIL;
  
     memcpy(pVB, Vertexes, sizeof Vertexes);
     
     pVertexBuffer-&gt;Unlock();
     
     return S_OK;
  }
  
  LRESULT CALLBACK MainWinProc(HWND hwnd, 
                               UINT msg,
                               WPARAM wparam, 
                               LPARAM lparam) 
  {
     switch(msg)
     {
        case WM_PAINT:
              RenderingDirect3D();
              ValidateRect(hwnd, NULL);
              break;
        case WM_DESTROY:
              DeleteDirect3D();
              PostQuitMessage(0);
              return 0;
     }
     return DefWindowProc(hwnd, msg, wparam, lparam);
  }
  
  int WINAPI WinMain(HINSTANCE hinstance,
                     HINSTANCE hprevinstance,
                     LPSTR lpcmdline, 
                     int ncmdshow) 
  {
     WNDCLASSEX windowsclass;
     HWND hwnd; 
     MSG msg; 
     //
     windowsclass.cbSize=sizeof(WNDCLASSEX);
     windowsclass.style=CS_DBLCLKS|CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
     windowsclass.lpfnWndProc=MainWinProc;
     windowsclass.cbClsExtra=0;
     windowsclass.cbWndExtra=0;
     windowsclass.hInstance=hinstance;
     windowsclass.hIcon=LoadIcon(NULL, IDI_APPLICATION);
     windowsclass.hCursor=LoadCursor(NULL, IDC_ARROW);
     windowsclass.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
     windowsclass.lpszMenuName=NULL;
     windowsclass.lpszClassName=_T(&quot;WINDOWSCLASS&quot;);
     windowsclass.hIconSm=LoadIcon(NULL, IDI_APPLICATION);
     
     if(!RegisterClassEx(&amp;windowsclass))
        return 0;
     
     if(!(hwnd=CreateWindowEx(
        NULL,
        _T(&quot;WINDOWSCLASS&quot;), 
        _T(&quot;Desenam litera G&quot;), 
        WS_OVERLAPPEDWINDOW|WS_VISIBLE, 
        CW_USEDEFAULT, 0, 
        CW_USEDEFAULT, 0, 
        NULL, 
        NULL, 
        hinstance, 
        NULL))) 
        return 0;
  
     if(SUCCEEDED(InitialDirect3D(hwnd)))
     {
        if(SUCCEEDED(InitialVertexBuffer()))
        {
           ShowWindow(hwnd, SW_SHOWDEFAULT); 
           UpdateWindow(hwnd); 
           ZeroMemory(&amp;msg, sizeof msg);
           while(msg.message!=WM_QUIT)
           {
              if(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
              {
                 TranslateMessage(&amp;msg);
                 DispatchMessage(&amp;msg);
              }
              else
                 RenderingDirect3D();
           }
        }
     }
  
     return msg.wParam;
  }
  </code></pre>