c++ - Error LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ) -


severity code description project file line error lnk2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@yahxz) severity code description project file line error lnk1120 1 unresolved externals

   #include "windows.h"     #include "tchar.h"     #include "d3d9.h"     #pragma comment(lib, "d3d9.lib")  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->getadapterdisplaymode(d3dadapter_default, &display)))       return e_fail;     d3dpresent_parameters direct3dparameter;    zeromemory(&direct3dparameter, sizeof direct3dparameter);     direct3dparameter.windowed=true;    direct3dparameter.swapeffect=d3dswapeffect_discard;    direct3dparameter.backbufferformat=display.format;      if(failed(pdirect3d->createdevice(d3dadapter_default, d3ddevtype_hal, hvnd,                                      d3dcreate_hardware_vertexprocessing,                                      &direct3dparameter, &pdirect3ddevice)))       return e_fail;    return s_ok; } hresult renderingdirect3d() {    if(pdirect3ddevice==null)       return e_fail;    pdirect3ddevice->clear(0, null, d3dclear_target, d3dcolor_xrgb(90, 150, 100), 1.f, 0);     pdirect3ddevice->beginscene();      pdirect3ddevice->setstreamsource(0, pvertexbuffer, 0, sizeof(customvertex));     pdirect3ddevice->setfvf(d3dfvf_customvertex);         pdirect3ddevice->drawprimitive(d3dpt_linelist, 0, nv);     pdirect3ddevice->endscene();     pdirect3ddevice->present(null, null, null, null);     return s_ok; }  void deletedirect3d() {    if(pvertexbuffer)        pvertexbuffer->release();    if(pdirect3ddevice)        pdirect3ddevice->release();    if(pdirect3d)        pdirect3d->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 = 0;     while( < nv*2 )     {         u = 0.f;         for(int j = 0; j < 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->createvertexbuffer(nv*2*sizeof(customvertex), 0, d3dfvf_customvertex,         d3dpool_default, &pvertexbuffer, null)))             return e_fail;     void *pvb=null;    if(failed(pvertexbuffer->lock(0, sizeof vertexes, (void**)&pvb, 0)))       return e_fail;     memcpy(pvb, vertexes, sizeof vertexes);     pvertexbuffer->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("windowsclass");    windowsclass.hiconsm=loadicon(null, idi_application);      if(!registerclassex(&windowsclass))       return 0;     if(!(hwnd=createwindowex(       null,       _t("windowsclass"),        _t("desenam litera g"),        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(&msg, sizeof msg);          while(msg.message!=wm_quit)          {             if(peekmessage(&msg, null, 0, 0, pm_remove))             {                translatemessage(&msg);                dispatchmessage(&msg);             }             else                renderingdirect3d();          }       }    }     return msg.wparam; } 

i faced same problem , found out selected "new win32 application" instead of "new win32 console application". problem solved when switched. hope can you.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -