分解机怎么升级快:VC /MFC 这问题怎么解决 头文件! LINK2005

来源:百度文库 编辑:高校问答 时间:2024/05/08 12:18:04
我先新建了一个类CsocketClient,头文件是:socketClient.h
然后我在主对话框的头文件 ClientDLG.h里定义了 CsocketClient * m_client;
这时编译的话,会提示 CsocketClient 未定义; 然后我就在MYDLG.H前加了句#include "socketClient.h" 再编译 通过了;
可以问题来了 当我LINK的时候 出现了很多错误,如下:

:\专业相关\VC\网络通信\client\clientDlg.cpp(202) : warning C4101: 'numOfSend' : unreferenced local variable
Generating Code...
Linking...
网络通信Dlg.obj : error LNK2005: "public: __thiscall CAboutDlg::CAboutDlg(void)" (??0CAboutDlg@@QAE@XZ) already defined in clientDlg.obj
网络通信Dlg.obj : error LNK2005: "protected: virtual void __thiscall CAboutDlg::DoDataExchange(class CDataExchange *)" (?DoDataExchange@CAboutDlg@@MAEXPAVCDataExchange@@@Z) already defined in clientDlg.obj
网络通信Dlg.obj : error LNK2005: "protected: static struct AFX_MSGMAP const * __stdcall CAboutDlg::_GetBaseMessageMap(void)" (?_GetBaseMessageMap@CAboutDlg@@KGPBUAFX_MSGMAP@@XZ) already defined in clientDlg.obj
网络通信Dlg.obj : error LNK2005: "protected: virtual struct AFX_MSGMAP const * __thiscall CAboutDlg::GetMessageMap(void)const " (?GetMessageMap@CAboutDlg@@MBEPBUAFX_MSGMAP@@XZ) already defined in clientDlg.obj
网络通信Dlg.obj : error LNK2005: "protected: static struct AFX_MSGMAP const CAboutDlg::messageMap" (?messageMap@CAboutDlg@@1UAFX_MSGMAP@@B) already defined in clientDlg.obj
网络通信Dlg.obj : error LNK2005: "private: static struct AFX_MSGMAP_ENTRY const * const CAboutDlg::_messageEntries" (?_messageEntries@CAboutDlg@@0QBUAFX_MSGMAP_ENTRY@@B) already defined in clientDlg.obj
网络通信Dlg.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CsocketListen::~CsocketListen(void)" (??1CsocketListen@@UAE@XZ)
网络通信Dlg.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CsocketRec::~CsocketRec(void)" (??1CsocketRec@@UAE@XZ)
网络通信Dlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CsocketRec::CsocketRec(void)" (??0CsocketRec@@QAE@XZ)
网络通信Dlg.obj : error LNK2001: unresolved external symbol "public: __thiscall CsocketListen::CsocketListen(void)" (??0CsocketListen@@QAE@XZ)
Debug/client.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

错误原因大致是CsocketClient.h 的头文件重定义了. 是不是编译了两次呢?
该怎么解决?? 我查了很多资料 都没搞定 头都大了.. 请高人指点 谢谢

头文件要养成增加避免重复包含的宏,如socketClient.h

//socketClient.h
#ifndef __SOCKETCLIENT_H__ //自己起个名字
#define __SOOCKETCLIENT_H__

...//头文件内容

#endif

对你的头文件进行类似上述的修改,然后
菜单: 工程->清洁 再重新编译