linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/mywin.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe.
mywin.exe - 2 error(s), 0 warning(s) ///////////////////////////////////////////////////////////////////////
我是菜鸟。 这是我照着抄的一个windows 程序,编译通过了 但是不能构建.exe文件,不能执行.上面是出错信息, 只知道字面什么意思,但不知道含义.到底怎么了 ? 那位高手给讲讲????先谢谢了!!
///////////////////////////////////////////////////////////////////////// 下面是原程序: #include<windows.h>
#include<string.h> #include<stdio.h> LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM); char szWinName[]="MyWin"; //name of the window. char str[255] =" "; //hold output string.
int WINAPI WinMain(HINSTANCE hThisInst,HINSTANCE hPrevInst, LPSTR lpszArgs,int nWinMode) {
HWND hwnd; MSG msg; tagWNDCLASSEXA wcl; //define a window class. wcl.cbSize=sizeof(tagWNDCLASSEXA); wcl.hInstance = hThisInst; // handle to this instance wcl.lpszClassName=szWinName;//window class name wcl.lpfnWndProc=WindowFunc;// window function wcl.style=0; // default style
wcl.hIcon=LoadIcon(NULL,IDI_APPLICATION);//standard icon wcl.hIconSm=LoadIcon(NULL,IDI_WINLOGO); //SMALL icon wcl.hCursor=LoadCursor(NULL,IDC_ARROW);//CURSOR style
wcl.lpszMenuName=NULL;//no menu wcl.cbClsExtra=0; // no extra wcl.cbWndExtra=0;// no information needed
//make the window white wcl.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
// register the window class if(!RegisterClassExA(&wcl))return 0;
//now that a window class has been registered ,a window //can be created. hwnd=CreateWindow( wcl.lpszClassName,// name of the window "Processing WM_CHAR Messages",//title WS_OVERLAPPEDWINDOW,//window style -normal CW_USEDEFAULT,// CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, // NO PARENT WINDOW NULL, // NO MENU hThisInst, // handle of this instance of program NULL //no additional arguments ); // display the window ShowWindow(hwnd,nWinMode); UpdateWindow(hwnd);
//create the message loop while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg);// DispatchMessage(&msg); //return cotrol to window 98 }
return msg.wParam;
} // this function is called by window 98 an is passed message // from the message queue
LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message, WPARAM wParam,LPARAM lParam) { HDC hdc;
switch(message){ case WM_CHAR: hdc=GetDC(hwnd); TextOut(hdc,1,1," ",3); printf(str,"%c",(char)wParam); TextOut(hdc,1,1,str,strlen(str)); ReleaseDC(hwnd,hdc); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd,message,wParam,lParam); }
return 0; }