📄 subject_30965.htm
字号:
<p>
序号:30965 发表者:member 发表日期:2003-02-28 00:28:17
<br>主题:链接错误求教!
<br>内容:从《windows程序设计》书上copy源代码,build时出现链接错误,5555<BR>哪为高手帮帮忙,谢谢了~~<BR><BR>错误信息如下:<BR>--------------------Configuration: HELLOWIN - Win32 Debug--------------------<BR>Linking...<BR>LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main<BR>Debug/HELLOWIN.exe : fatal error LNK1120: 1 unresolved externals<BR>Error executing link.exe.<BR><BR>HELLOWIN.exe - 2 error(s), 0 warning(s)<BR><BR><BR>源代码如下:<BR>HELLOWIN.C<BR>/*------------------------------------------------------------<BR> HELLOWIN.C -- Displays "Hello, Windows 98!" in client area<BR> (c) Charles Petzold, 1998<BR> ------------------------------------------------------------*/<BR><BR>#include <windows.h><BR><BR>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;<BR><BR>int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,<BR> PSTR szCmdLine, int iCmdShow)<BR>{<BR> static TCHAR szAppName[] = TEXT ("HelloWin") ;<BR> HWND hwnd ;<BR> MSG msg ;<BR> WNDCLASS wndclass ;<BR><BR> wndclass.style = CS_HREDRAW | CS_VREDRAW ;<BR> wndclass.lpfnWndProc = WndProc ;<BR> wndclass.cbClsExtra = 0 ;<BR> wndclass.cbWndExtra = 0 ;<BR> wndclass.hInstance = hInstance ;<BR> wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;<BR> wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;<BR> wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;<BR> wndclass.lpszMenuName = NULL ;<BR> wndclass.lpszClassName = szAppName ;<BR><BR> if (!RegisterClass (&wndclass))<BR> {<BR> MessageBox (NULL, TEXT ("This program requires Windows NT!"), <BR> szAppName, MB_ICONERROR) ;<BR> return 0 ;<BR> }<BR> hwnd = CreateWindow (szAppName, // window class name<BR> TEXT ("The Hello Program"), // window caption<BR> WS_OVERLAPPEDWINDOW, // window style<BR> CW_USEDEFAULT, // initial x position<BR> CW_USEDEFAULT, // initial y position<BR> CW_USEDEFAULT, // initial x size<BR> CW_USEDEFAULT, // initial y size<BR> NULL, // parent window handle<BR> NULL, // window menu handle<BR> hInstance, // program instance handle<BR> NULL) ; // creation parameters<BR> <BR> ShowWindow (hwnd, iCmdShow) ;<BR> UpdateWindow (hwnd) ;<BR> <BR> while (GetMessage (&msg, NULL, 0, 0))<BR> {<BR> TranslateMessage (&msg) ;<BR> DispatchMessage (&msg) ;<BR> }<BR> return msg.wParam ;<BR>}<BR><BR>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<BR>{<BR> HDC hdc ;<BR> PAINTSTRUCT ps ;<BR> RECT rect ;<BR> <BR> switch (message)<BR> {<BR> case WM_CREATE:<BR> PlaySound (TEXT ("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC) ;<BR> return 0 ;<BR><BR> case WM_PAINT:<BR> hdc = BeginPaint (hwnd, &ps) ;<BR> <BR> GetClientRect (hwnd, &rect) ;<BR> <BR> DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,<BR> DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;<BR> EndPaint (hwnd, &ps) ;<BR> return 0 ;<BR> <BR> case WM_DESTROY:<BR> PostQuitMessage (0) ;<BR> return 0 ;<BR> }<BR> return DefWindowProc (hwnd, message, wParam, lParam) ;<BR>}<BR><BR><BR>系统配置如下:<BR>win2k + visual c++6.0
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:守护神 回复日期:2003-02-28 07:24:25
<br>内容:Unresolved externals<BR>这是典型的链接错误,最常见的原因是用了一个外部变量或在别的模块里定义的函数却没有声明。<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:我扭我扭我扭扭扭 回复日期:2003-02-28 08:02:09
<br>内容:WinMain()是Win32的入口函数,你是不是把它写在Win32 Console里了?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:member 回复日期:2003-02-28 08:30:12
<br>内容:nono,建立的workspace为Win32 Application
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:member 回复日期:2003-02-28 08:39:12
<br>内容:问题解决了,在Project中的Setting中,选Link选项,把/subsystem:console改为/subsystem:windows
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -