LINK时出错!

ML20 2003-01-25 12:59:00
//Hello.h
class CMyApp:public CWinApp{
public:
virtual BOOL InitInstance();
};

class CMainWindow:public CFrameWnd{
public:
CMainWindow();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
//Hello.cpp
#include <afxwin.h>
#include "Hello.h"

CMyApp myApp;

BOOL CMyApp::InitInstance(){
m_pMainWnd=new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

BEGIN_MESSAGE_MAP(CMainWindow,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()


CMainWindow::CMainWindow(){
Create(NULL,_T("The Hello Application"));
}

void CMainWindow::OnPaint(){
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
dc.DrawText(_T("Hello,MFC"),-1,&rect,
DT_SINGLELINE|DT_CENTER|DT_VCENTER);
}
结果连接时出错,以下是错误信息,请问这是怎么一回事?我该怎么做?
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Hello.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

Hello.exe - 4 error(s), 0 warning(s)
...全文
48 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Mutu20 2003-05-10
  • 打赏
  • 举报
回复
还是别学VC了。
DoubleJiang 2003-01-27
  • 打赏
  • 举报
回复
你有没有用VC 的 Wiazrd
ML20 2003-01-27
  • 打赏
  • 举报
回复
还是不对。
zswzwy 2003-01-25
  • 打赏
  • 举报
回复
Example

/* BEGTHRD.C illustrates multiple threads using functions:
*
* _beginthread _endthread
*
*
* This program requires the multithreaded library. For example,
* compile with the following command line:
* CL /MT /D "_X86_" BEGTHRD.C
*
* If you are using the Visual C++ development environment, select the
* Multi-Threaded runtime library in the compiler Project Options dialog
* box.
*
*/

#include <windows.h>
#include <process.h> /* _beginthread, _endthread */
#include <stddef.h>
#include <stdlib.h>
#include <conio.h>

void Bounce( void *ch );
void CheckKey( void *dummy );

/* GetRandom returns a random integer between min and max. */
#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))

BOOL repeat = TRUE; /* Global repeat flag and video variable */
HANDLE hStdOut; /* Handle for console window */
CONSOLE_SCREEN_BUFFER_INFO csbi; /* Console information structure */

void main()
{
CHAR ch = 'A';

hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );

/* Get display screen's text row and column information. */
GetConsoleScreenBufferInfo( hStdOut, &csbi );

/* Launch CheckKey thread to check for terminating keystroke. */
_beginthread( CheckKey, 0, NULL );

/* Loop until CheckKey terminates program. */
while( repeat )
{
/* On first loops, launch character threads. */
_beginthread( Bounce, 0, (void *) (ch++) );

/* Wait one second between loops. */
Sleep( 1000L );
}
}

/* CheckKey - Thread to wait for a keystroke, then clear repeat flag. */
void CheckKey( void *dummy )
{
_getch();
repeat = 0; /* _endthread implied */

}

/* Bounce - Thread to create and and control a colored letter that moves
* around on the screen.
*
* Params: ch - the letter to be moved
*/
void Bounce( void *ch )
{
/* Generate letter and color attribute from thread argument. */
char blankcell = 0x20;
char blockcell = (char) ch;
BOOL first = TRUE;
COORD oldcoord, newcoord;
DWORD result;


/* Seed random number generator and get initial location. */
srand( _threadid );
newcoord.X = GetRandom( 0, csbi.dwSize.X - 1 );
newcoord.Y = GetRandom( 0, csbi.dwSize.Y - 1 );
while( repeat )
{
/* Pause between loops. */
Sleep( 100L );

/* Blank out our old position on the screen, and draw new letter. */
if( first )
first = FALSE;
else
WriteConsoleOutputCharacter( hStdOut, &blankcell, 1, oldcoord, &result );
WriteConsoleOutputCharacter( hStdOut, &blockcell, 1, newcoord, &result );

/* Increment the coordinate for next placement of the block. */
oldcoord.X = newcoord.X;
oldcoord.Y = newcoord.Y;
newcoord.X += GetRandom( -1, 1 );
newcoord.Y += GetRandom( -1, 1 );

/* Correct placement (and beep) if about to go off the screen. */
if( newcoord.X < 0 )
newcoord.X = 1;
else if( newcoord.X == csbi.dwSize.X )
newcoord.X = csbi.dwSize.X - 2;
else if( newcoord.Y < 0 )
newcoord.Y = 1;
else if( newcoord.Y == csbi.dwSize.Y )
newcoord.Y = csbi.dwSize.Y - 2;

/* If not at a screen border, continue, otherwise beep. */
else
continue;
Beep( ((char) ch - 'A') * 100, 175 );
}
/* _endthread given to terminate */
_endthread();
}


ML20 2003-01-25
  • 打赏
  • 举报
回复
好的,我试试
zswzwy 2003-01-25
  • 打赏
  • 举报
回复
setting->link->LIBCMT.LIB
setting->link->MSVCRT.LIB
yuanquana 2003-01-25
  • 打赏
  • 举报
回复
据说这种错误不好整的。
zswzwy 2003-01-25
  • 打赏
  • 举报
回复
不行在加入
LIBCMT.LIB
MSVCRT.LIB
zswzwy 2003-01-25
  • 打赏
  • 举报
回复
#include <process.h>

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧