diego2la
diego2la

Reputation: 97

Solution with 2 project does not compile

I've got solution with 2 projects. In first project I've got Frame and some controls, in second - CForcesEditorDialog:CDialog. Ofcouse I whant to compare them. But this error don't give me compile project:

MainFrame.obj : error LNK2019: unresolved external symbol "public: __thiscall CForcesEditorDialog::CForcesEditorDialog(class CWnd *,class MainFrame *)" (??0CForcesEditorDialog@@QAE@PAVCWnd@@PAVMainFrame@@@Z) referenced in function "protected: int __thiscall MainFrame::OnCreate(struct tagCREATESTRUCTA *)" (?OnCreate@MainFrame@@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;
}

May be I've got a problem with including this projects. I had never wite solution with 2 projects. Have you got any ideas about it ?

Upvotes: 3

Views: 195

Answers (4)

Javier De Pedro
Javier De Pedro

Reputation: 2239

You have a linkage error. Visual Studio finds CForcesEditorDialog at compile time but it didn't at link time. You have to add the .lib file of the second project in the project settings of the first one (Property Pages -> Linker -> Input -> Additional Dependencies).

Hope it helps.

Upvotes: 3

JohnCz
JohnCz

Reputation: 1609

Is CForcesEditorDialog part of the project you compile? In other words is implementation file (cpp) for CForcesEditorDialog included in a project giving you this error message? Is it a part of another project or DLL?

Upvotes: 1

Scott Langham
Scott Langham

Reputation: 60391

What type of project is CForcesEditorDialog in? Is it a static lib or a dynamic dll?

If it's dynamic, you will need to export the functions and classes from the dll that you want to use in your exe. This tutorial mentions exporting: http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c4017/MFC-DLL-TUTORIAL-PART-1.htm

With AFX_EXT_CLASS. You would use it in your class declaration to export it from your dll, e.g.:

class AFX_EXT_CLASS CForcesEditorDialog : public CDialog
{

Upvotes: 0

fazo
fazo

Reputation: 1827

try cut -pasting class CForcesEditorDialog before class MainFrame

should do the trick

Upvotes: 0

Related Questions