我在编写VC++源程序时,写好后,compile编译后为0个错误0个警告,而在build时却出现了几个错误,所有的源程序都是如此。排除了所装软件的问题(我已经试装过不同版本的很多VC++都是如此)请问这是怎么回事,急!!!
万分感谢!!!!!
#include "windows.h" LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);//声明消息处理函数
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int);//声明程序入口函数 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdline, int nCmdShow)//程序入口函数定义 { WNDCLASS wcApp; MSG msg; HWND ghWnd=NULL; char*szAppName="Windows API Application"; char*szAppTitle="Windows API窗口程序"; wcApp.style=CS_HREDRAW; wcApp.lpfnWndProc=WndProc; wcApp.cbWndExtra=0; wcApp.cbClsExtra=0; wcApp.hInstance=hInstance; wcApp.hIcon=LoadIcon(NULL,IDI_WINLOGO); wcApp.hCursor=LoadCursor(NULL,IDC_ARROW); wcApp.hbrBackground=(HBRUSH)COLOR_ACTIVEBORDER; wcApp.lpszMenuName=NULL; wcApp.lpszClassName=szAppName; RegisterClass(&wcApp); ghWnd=CreateWindow(szAppName, szAppTitle, WS_OVERLAPPEDWINDOW, 100, 100, 350, 300, NULL, NULL, hInstance, NULL); if(NULL==ghWnd) return 0; ShowWindow(ghWnd,nCmdShow); UpdateWindow(ghWnd); while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { char*msgCreate="收到WM—CREATE消息,建立窗口";
char*msgDestroy="收到WM—DESTROY消息,窗口关闭"; char*msgCaption="收到消息"; char*msgLBTN="标左键按下"; switch(message) { case WM_CREATE: MessageBox(GetFocus(),msgCreate,msgCaption,MB_OK|MB_ICONEXCLAMATION); break; case WM_LBUTTONDOWN: MessageBox(GetFocus(),msgLBTN,msgCaption,MB_OK|MB_ICONINFORMATION); break; case WM_DESTROY: MessageBox(GetFocus(),msgDestroy,msgCaption,MB_OK|MB_ICONHAND); PostQuitMessage(0); break; default: return DefWindowProc(hwnd,message,wParam,lParam); } return FALSE; }
我也上机试了一下的!!! 连接时有这两个错误 : Configuration: heike - Win32 Debug-------------------- Linking... LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/heike.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe.
heike.exe - 2 error(s), 0 warning(s) 现在我也想知道为什么啊???!!!!!!!!!
我上机调试了一下,有这样的错误: LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main Debug/245o.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe.
245o.exe - 2 error(s), 0 warning(s) 我刚学C++,也不懂,还望哪位高手帮忙解决!