我有2个项目的解决方案。 在第一个项目中,我有Frame和一些控件,第二个 - CForcesEditorDialog:CDialog。 我想要比较一下。 但是这个错误并没有给我编译项目:
MainFrame.obj:错误LNK2019:未解析的外部符号“public: __thiscall CForcesEditorDialog :: CForcesEditorDialog(类CWnd *,类MainFrame *)“(?? 0CForcesEditorDialog @@ QAE @ PAVCWnd @@ PAVMainFrame @@@ Z) 在函数“protected:int __thiscall中引用 MainFrame :: OnCreate(struct tagCREATESTRUCTA *)“ (?的OnCreate @ @@大型机@@@ IAEHPAUtagCREATESTRUCTA Z)
class CForcesEditorDialog;
class MainFrame : public CFrameWnd
{
CForcesEditorDialog* forcesEditorDialog;
public:
MainFrame();
~MainFrame();
//virtual void CreateChildControls( void );
//afx_msg void OnMouseMove(UINT, CPoint);
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
DECLARE_MESSAGE_MAP()
};
int MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
forcesEditorDialog = new CForcesEditorDialog(this,this);//CForcesEditorDialog(this,this);
}
class CForcesEditorDialog : public CDialog
{
//For including ForcesBar
ForcesBar* m_forcesBar;
MainFrame* pMainFrame;
public:
CForcesEditorDialog(CWnd* _pParentWnd = NULL, MainFrame* _pMainFrame = NULL); // standard constructor
}
CForcesEditorDialog::CForcesEditorDialog(CWnd* _pParentWnd, MainFrame* _pMainFrame)
: CDialog(IDD_CUR_DIALOG, _pParentWnd),
p_expander (0),
p_selectedItem(0),
m_enabled (false)
{
m_forcesBar = new ForcesBar();
pMainFrame = _pMainFrame;
}
可能我在包含这个项目时遇到了问题。我从未尝试过2个项目的解决方案。你有什么想法吗?
答案 0 :(得分:3)
您有链接错误。 Visual Studio在编译时查找CForcesEditorDialog,但它不在链接时查找。您必须在第一个项目(Property Pages -> Linker -> Input -> Additional Dependencies)的项目设置中添加第二个项目的.lib文件。
希望它有所帮助。
答案 1 :(得分:1)
CForcesEditorDialog是你编译的项目的一部分吗?换句话说,包含在项目中的CForcesEditorDialog的实现文件(cpp)给出了此错误消息? 它是另一个项目或DLL的一部分吗?
答案 2 :(得分:0)
尝试在类MainFrame
之前剪切类CForcesEditorDialog应该做的伎俩
答案 3 :(得分:0)
CForcesEditorDialog属于哪种类型的项目?它是静态库还是动态DLL?
如果它是动态的,您将需要从您想要在exe中使用的dll中导出函数和类。本教程提到导出:http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c4017/MFC-DLL-TUTORIAL-PART-1.htm
使用AFX_EXT_CLASS。您可以在类声明中使用它从您的dll中导出它,例如:
class AFX_EXT_CLASS CForcesEditorDialog : public CDialog
{