问一个婴儿级问题
vc 6.0
win2000
我编译一个程序(一个简单的窗口,和一个about对话框),compile是没问题,但在生成的时候出现了如下的link21错误:
--------------------Configuration: generic - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/generic.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
generic.exe - 2 error(s), 0 warning(s)
我不知该如何解决?清高手赐教,多谢了!!!
问题点数:20、回复次数:5Top
1 楼andone(结果没有结果)回复于 2003-12-03 09:40:02 得分 5
Link出错吧,你看看编译开关,把GZ改成GM试一试吧。Top
2 楼arvid_gs(west)回复于 2003-12-03 10:12:07 得分 5
GZ改成GMTop
3 楼byybyybyy(henry)回复于 2003-12-04 22:50:21 得分 0
还是不行啊,GZ和GM有什么区别呀?我现在的Project ->setting里面是这样的
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Debug/generic.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GM /c
我建工程的时候是用的win32 console app,后来又拷代码过来的,代码如下:
//---------------------------------------------------------------------
//---------------------------------------------------------------------
#include <windows.h>
#include "resource.h"
#include "generic.h"
HINSTANCE _hInst; // Instance handle
HWND _hWnd;
char _szAppName[] = "Generic"; // program name
char _szTitle[] = "Generic Sample Application"; // window caption
//---------------------------------------------------------------------
// WinMain program entry
//---------------------------------------------------------------------
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
UNREFERENCED_PARAMETER(lpCmdLine); // to avoid the compiling warning
if (!hPrevInstance)
if (!InitApplication(hInstance))
return (FALSE);
if (!InitInstance(hInstance, nCmdShow))
return (FALSE);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam); // give back PostQuitMessage's parameter
}
//---------------------------------------------------------------------
// InitApplication - register window class
//---------------------------------------------------------------------
BOOL InitApplication(HINSTANCE hInstance)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WndProc; // window function
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, "jjhouricon");
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(WHITE_BRUSH); // window background color
wc.lpszMenuName = "GenericMenu"; // .RC define window
wc.lpszClassName = _szAppName;
return (RegisterClass(&wc));
}
//---------------------------------------------------------------------
// InitInstance - create window
//---------------------------------------------------------------------
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
_hInst = hInstance; // save as a global proptey ,using easy
_hWnd = CreateWindow(
_szAppName,
_szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if (!_hWnd)
return (FALSE);
ShowWindow(_hWnd, nCmdShow); // display window
UpdateWindow(_hWnd); // deliver WM_PAINT
return (TRUE);
}
//---------------------------------------------------------------------
// WndProc - WINDOW function
//---------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (message) {
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId) {
case IDM_ABOUT:
DialogBox(_hInst,
"AboutBox", // dialog resource name
hWnd, // parent window
(DLGPROC)About // dialog function window
);
break;
case IDM_EXIT:
// the user who end the program, the process type is samiler as system
DestroyWindow (hWnd);
break;
default:
return (DefWindowProc(hWnd, message, wParam, lParam));
}
break;
case WM_DESTROY: // window had been destroyed(the program will end right now)
PostQuitMessage(0);
break;
default:
return (DefWindowProc(hWnd, message, wParam, lParam));
}
return (0);
}
//---------------------------------------------------------------------
// About - dialog function
//---------------------------------------------------------------------
LRESULT CALLBACK About(HWND hDlg, UINT message,
WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam); // To avoid compile's warning
switch (message) {
case WM_INITDIALOG:
return (TRUE); // TRUE it express i had processed this message
case WM_COMMAND:
if (LOWORD(wParam) == IDOK
|| LOWORD(wParam) == IDCANCEL) {
EndDialog(hDlg, TRUE);
return (TRUE); // TRUE it express i had processed this message
}
break;
}
return (FALSE); // FALSE it express i had processed this message
}
//------------------------ end of file ------------------------------
Top
4 楼linyudie(蝴蝶夜雪)回复于 2003-12-04 23:09:05 得分 5
控制台工程的入口点是main,不是WinMainTop
5 楼sxslyy(孤松傲雪)回复于 2003-12-05 08:49:16 得分 5
工程用的win32 app.
win32 console app入口点是main
Top




