我正在开展一个对我来说很新的项目。我有一个非常基本的C ++知识,我只是无法修复我在尝试使用VC ++构建项目时遇到的链接器错误。以下是涉及的2个类的错误和定义。
1>Dlg_Container_View.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall CPictureCtrl::~CPictureCtrl(void)" (??1CPictureCtrl@@UAE@XZ) referenced in function __unwindfunclet$??0CDlg_Container_View@@QAE@PAVCWnd@@@Z$0
1>Dlg_Container_View.obj : error LNK2019: unresolved external symbol "public: __thiscall CPictureCtrl::CPictureCtrl(void)" (??0CPictureCtrl@@QAE@XZ) referenced in function "public: __thiscall CDlg_Container_View::CDlg_Container_View(class CWnd *)" (??0CDlg_Container_View@@QAE@PAVCWnd@@@Z)
1>Dlg_Container_View.obj : error LNK2019: unresolved external symbol "public: int __thiscall CPictureCtrl::Load(class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > &)" (?Load@CPictureCtrl@@QAEHAAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) referenced in function "protected: virtual int __thiscall CDlg_Container_View::OnInitDialog(void)" (?OnInitDialog@CDlg_Container_View@@MAEHXZ)
1>.\Debug/EDiscovery.exe : fatal error LNK1120: 3 unresolved externals
以下是类定义(我认为是相关的。我只是复制粘贴完全定义,这可能是无关紧要但我不想错过任何东西)。对不起这个基本问题。
class CPictureCtrl :
public CStatic
{
public:
//Constructor
CPictureCtrl(void);
//Destructor
~CPictureCtrl(void);
public:
//Loads an image from a file
BOOL LoadFromFile(CString &szFilePath);
//Loads an image from an IStream interface
BOOL LoadFromStream(IStream* piStream);
//Loads an image from a byte stream;
BOOL LoadFromStream(BYTE* pData, size_t nSize);
//Loads an image from a Resource
// BOOL LoadFromResource(HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
//Overload - Single load function
BOOL Load(CString &szFilePath);
BOOL Load(IStream* piStream);
BOOL Load(BYTE* pData, size_t nSize);
// BOOL Load(HMODULE hModule, LPCTSTR lpName, LPCTSTR lpType);
//Frees the image data
void FreeData();
protected:
virtual void PreSubclassWindow();
//Draws the Control
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual BOOL OnEraseBkgnd(CDC* pDC);
private:
//Internal image stream buffer
IStream* m_pStream;
//Control flag if a pic is loaded
BOOL m_bIsPicLoaded;
//GDI Plus Token
ULONG_PTR m_gdiplusToken;
};
上面的类在头文件PictureCtrl.h中定义,该文件包含在定义了以下类的文件中。以下是具有上述类的对象作为成员变量的类:
class CDlg_Container_View : public CDialog , public CParentIView
{
// Construction
public:
CDlg_Container_View(CWnd* pParent = NULL);
~CDlg_Container_View();
CDialog * GetDialog(const int idx);
void ClosePages();
virtual void SetCurSel(const int idx);
void AddPage(const char * cText, CDialog * pDlg, const UINT id);
CPtrArray pPages;
CStringArray csText;
CUIntArray csIds;// standard constructor
int iCurIdx;
CString csTitle;
virtual void Show_Dialog();
virtual void Hide_Dialog();
virtual void RegisterChildToParent(CString,CIView*);
virtual void ChangeBtnState(CString p_strBtnName,BOOL flag);
void SetControlText();
void ResetDialog();
void ShowMessageBox(CString msg);
void EnableProject(bool p_blFlag);
CFont m_StaticFont;
// virtual void fun();
// standard constructor
// Dialog Data
//{{AFX_DATA(CDlg_Container_View)
enum { IDD = IDD_DLG_CONTAINER_VIEW_DIALOG };
CRichEditCtrl m_REdit_DisplayProjectNots;
CRichEditCtrl m_REdit_AddProjectNotes;
CButton m_Grp_Bx_Project_Notes;
CButton m_btn_Report;
CButton m_btn_Export;
CButton m_btn_Error;
CStatic m_Lbl_Token_Balance;
CButton m_Btn_Add_Notes;
CStatic m_Lbl_Project;
CButton m_btn_Collect;
CComboBox m_Combo_Project_Name;
CStatic wndFrame;
CPictureCtrl m_picCtrl;
//CHyperLink m_hyper_Manage_Tokens;
CStatic m_hyper_Manage_Tokens;
CHyperLink m_WebIdHyperlink;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDlg_Container_View)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CBrush m_brush;
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CDlg_Container_View)
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
virtual BOOL OnInitDialog();
// afx_msg void OnBtnCollect();
afx_msg void OnBtnReport();
afx_msg void OnBtnExport();
afx_msg void OnBtnClose();
// afx_msg void OnSelendokCOMBOProjectName();
afx_msg void OnBtnError();
afx_msg void OnBtnAddNotes();
afx_msg void OnEditchangeCOMBOProjectName();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
CDlg_Container_Presenter *m_objCDlg_Container_Presenter;
BOOL m_blFirstTime_Collect;
BOOL m_blEnableButtons;
CString m_strProjectNote;
bool m_blFirsttime_Project;
//bool m_bAutoComplete;
CString m_sTypedText;
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnEnSetfocusReditDisplayprojectnotes();
// afx_msg void OnCbnDropdownComboProjectName();
afx_msg void OnBnClickedCheck1();
afx_msg void OnBnClickedCheck2();
// afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
// afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
// afx_msg void OnCbnSetfocusComboProjectName();
// afx_msg void OnCbnEditupdateComboProjectName();
afx_msg void OnCbnEditupdateComboProjectName();
afx_msg void OnCbnSelchangeComboProjectName();
//afx_msg void OnBnClickedBtnProjectEdit();
afx_msg void OnBnClickedBtnProjectEdit();
// afx_msg void OnCbnCloseupComboProjectName();
// afx_msg void OnCbnCloseupComboProjectName();
afx_msg void OnCbnCloseupComboProjectName();
afx_msg void OnBnClickedBtnCollect();
afx_msg void OnCbnSelendokComboProjectName();
CButton m_btn_Update_Project;
afx_msg void OnCbnDropdownComboProjectName();
afx_msg void OnBnClickedButton1();
afx_msg void OnStnClickedLblManageTokens();
void UpdateTokenCount();
CPictureCtrl m_LogoPic;
};
`
答案 0 :(得分:1)
那些链接器错误意味着您没有提供这三个函数的定义。 即构造函数,析构函数和加载函数......
CPictureCtrl(void);
~CPictureCtrl(void);
BOOL Load(CString &szFilePath);
答案 1 :(得分:0)
您的项目中是否包含PictureCtrl.cpp?