我在VC6里建了一个项目,名叫MYAPP
包含MyAPP.h和MyApp.cpp
MyAPP.h代码为: //application class
class CMyApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};//frame windows class
class CMyFrame: public CFrameWnd
{
public:
CMyFrame();
protected:
//"afx_msg" indicates that the next two functions are part
//of the MFC library message dispatch system
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};MyApp.cpp代码为:
#include <afxwin.h> // MFC library header file declares base classes
//#include <nafxcwd.lib>
#include "myapp.h"CMyApp theApp; //the one and only CMyapp objectBOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame();
m_pMainWnd ->ShowWindow(m_nCmdShow);m_pMainWnd ->UpdateWindow();
return TRUE;
}BEGIN_MESSAGE_MAP(CMyFrame,CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT()
END_MESSAGE_MAP()CMyFrame::CMyFrame()
{
Create(NULL,"MYAPP Applications");
}void CMyFrame::OnLButtonDown(UINT nFlags,CPoint point)
{
TRACE("Entering CMyFrame::OnLButtonDown -%lx,%d,%d\n"),
(long) nFlags,point.x,point.y;
}void CMyFrame::OnPaint()
{
CPaintDC dc(this);
dc.TextOut(0,0,"Hello,world!");
}编译通过没有出错,但build时出错,出现以下提示:
--------------------Configuration: MYAPP - Win32 Debug--------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/MYAPP.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.MYAPP.exe - 3 error(s), 0 warning(s)但设置ALT+F7->C/C++/->Catalog->Code Generation
MultiThread后,就可以正常build了。请问达人们这是为什么呢?
包含MyAPP.h和MyApp.cpp
MyAPP.h代码为: //application class
class CMyApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};//frame windows class
class CMyFrame: public CFrameWnd
{
public:
CMyFrame();
protected:
//"afx_msg" indicates that the next two functions are part
//of the MFC library message dispatch system
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};MyApp.cpp代码为:
#include <afxwin.h> // MFC library header file declares base classes
//#include <nafxcwd.lib>
#include "myapp.h"CMyApp theApp; //the one and only CMyapp objectBOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrame();
m_pMainWnd ->ShowWindow(m_nCmdShow);m_pMainWnd ->UpdateWindow();
return TRUE;
}BEGIN_MESSAGE_MAP(CMyFrame,CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT()
END_MESSAGE_MAP()CMyFrame::CMyFrame()
{
Create(NULL,"MYAPP Applications");
}void CMyFrame::OnLButtonDown(UINT nFlags,CPoint point)
{
TRACE("Entering CMyFrame::OnLButtonDown -%lx,%d,%d\n"),
(long) nFlags,point.x,point.y;
}void CMyFrame::OnPaint()
{
CPaintDC dc(this);
dc.TextOut(0,0,"Hello,world!");
}编译通过没有出错,但build时出错,出现以下提示:
--------------------Configuration: MYAPP - Win32 Debug--------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/MYAPP.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.MYAPP.exe - 3 error(s), 0 warning(s)但设置ALT+F7->C/C++/->Catalog->Code Generation
MultiThread后,就可以正常build了。请问达人们这是为什么呢?
解决方案 »
- MFC对话框程序点了右上角的"X",在任务管理器中未关闭
- ip报头
- 系统菜单如何自绘,网络搜不到,浩方软件的系统菜单自绘是如何实现的?
- MFC中listbox的滚动条的滑块大小如何设定?
- 求购<<directinput原理与api参考>>这本书,纸书好像没见有卖的了,谁有电子版传我,可以付费,有的或知道的帮个忙吧。(详细见帖内)
- 将WM_DEVICECHANGE传给windows 强制使其刷新,这种方法行得通吗?
- 紧急求教:如何去除或遮盖MSFLEXGRID控件的某一单元格的下格线或上格线。
- 按钮怎么了?
- 新手问题:如何改变客户区的颜色?
- purgeComm(PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR)写操作之后,执行清空问题
- windows 资源管理器的地址栏的列表框如果实现,有没有这样的控件?
- 请高手指点一下,“不同类型的包模拟不同的客户端发送”怎样实现?我想在服务器端直接根据包的类型不同做出相应的回应
//主要原因是在VC6 Project->Settings->General->Microsoft Foundation Class:选择使用MFC Static
Libary.或MFC Dynamic Libary.就好了.很都书都抄这样的一个例子。只是给读者说建立一个Win32工程。把这些文件包含过去。就可以了,对于初学者来说....-----》可以了吗? VC的程序本来初学就比别的开发工具难.让初学者觉得VC很难。其实是一些书误人子弟。
你的意思是说程序未包括MFC库,所以出错,是这样理解么?