c - Why is my Windows program trying to call main() instead of WinMain()? -


i'm trying make first steps opengl.

however seems not happen because of error coming while trying debug solution:

msvcrtd.lib(crtexe.obj) : error lnk2019: unresolved external symbol main referenced in function __tmaincrtstartup

i understand complier wants see int main() ..., doesn't see winmain call?

here code:

#include <windows.h> #include <stdio.h> #include <stdlib.h>  typedef struct {     hwnd hwnd; } glab_t;  static glab_t glab;  char szclassname[ ] = "glab";  static lresult callback windowprocedure (hwnd hwnd, uint message, wparam wparam, lparam lparam) {     switch (message) {         case wm_destroy:             postquitmessage (0);             break;         default:             return defwindowproc (hwnd, message, wparam, lparam);     }      return 0; }   int winapi winmain (hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int ncmdshow) {      msg messages;     rect rect;     wndclassex wndclass;     int screenwidth, screenheight;     int x, y, w, h;      screenwidth = getsystemmetrics(sm_cxscreen);     screenheight = getsystemmetrics(sm_cyscreen);      rect.left = (screenwidth - 582) / 2;     rect.top = (screenheight - 358) / 2;     rect.right = rect.left + 582;     rect.bottom = rect.top + 358;      x = rect.left;     y = rect.top;     w = 640;     h = 480;        wndclass.hinstance = hinstance;     wndclass.lpszclassname = szclassname;     wndclass.lpfnwndproc = windowprocedure;     wndclass.style = cs_dblclks;     wndclass.cbsize = sizeof (wndclassex);     wndclass.hicon = loadicon (null, idi_application);     wndclass.hiconsm = loadicon (null, idi_application);     wndclass.hcursor = loadcursor (null, idc_arrow);     wndclass.lpszmenuname = null;     wndclass.cbclsextra = 0;     wndclass.cbwndextra = 0;     wndclass.hbrbackground = (hbrush)(color_btnface + 1);      if (!registerclassex (&wndclass)) {         return 0;     }      glab.hwnd = createwindowex (            0,            szclassname,            "glab - opengl",            ws_overlappedwindow,            x,            y,            w,            h,            hwnd_desktop,            null,            hinstance,            null             );      showwindow (glab.hwnd, ncmdshow);     while (getmessage (&messages, null, 0, 0)) {         translatemessage(&messages);         dispatchmessage(&messages);     }      return true; } 

i'm using ms visual c++ 2010 express.

you have project of subsystem console instead of windows. change project properties, , work. that's in linker -> system -> subsystem.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -