3

私は2つのプロジェクトで解決策を持っています。最初のプロジェクトでは、Frame といくつかのコントロールがあり、2 番目のプロジェクトでは CForcesEditorDialog:CDialog があります。もちろん、それらを比較したいと思います。しかし、このエラーではプロジェクトをコンパイルできません:

MainFrame.obj : エラー LNK2019: 未解決の外部シンボル "public: __thiscall CForcesEditorDialog::CForcesEditorDialog(class CWnd *,class MainFrame *)" (??0CForcesEditorDialog@@QAE@PAVCWnd@@PAVMainFrame@@@Z) 関数で参照されている "保護されています: 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;
}

このプロジェクトを含めることに問題があるかもしれません。私は2つのプロジェクトで解決策を考えたことはありませんでした。それについて何かアイデアはありますか?

4

4 に答える 4

3

リンクエラーがあります。Visual Studio はコンパイル時に CForcesEditorDialog を見つけますが、リンク時には見つけませんでした。最初のプロジェクトのプロジェクト設定で、2 番目のプロジェクトの .lib ファイルを追加する必要があります (プロパティ ページ -> リンカー -> 入力 -> 追加の依存関係)。

それが役に立てば幸い。

于 2012-04-30T06:48:47.117 に答える
1

CForcesEditorDialog は、コンパイルするプロジェクトの一部ですか? つまり、CForcesEditorDialog の実装ファイル (cpp) がプロジェクトに含まれているため、このエラー メッセージが表示されますか? 別のプロジェクトまたは DLL の一部ですか?

于 2012-04-29T16:21:11.893 に答える
0

クラスMainFrameの前にクラスCForcesEditorDialogをカットアンドペーストしてみてください

トリックを行う必要があります

于 2012-04-29T14:10:11.783 に答える
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
{
于 2012-04-29T14:38:41.323 に答える