Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Link error question

Link error question

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++tutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GDavy
    wrote on last edited by
    #1

    I got a linking problem. I think it has something to do with MFC and such but I`m not sure.. The problem is as follows: I made a .dll file and in it is a class derived from CDialog, something like: #ifdef __DLL_BUILD__ #define LD_DECSPEC __declspec(dllexport) #else #define LD_DECSPEC __declspec(dllimport) #endif class LD_DECSPEC CDllDialog : public CDialog { public: CDllDialog( CWnd* pParent = NULL ); CDllDialog( UINT nIDD, CWnd* pParent = NULL ); virtual ~CDllDialog(); // Dialog Data //{{AFX_DATA(CDllDialog ) // NOTE: the ClassWizard will add data members here //}}AFX_DATA enum{ ID_DLG_LOGOUT = 200 }; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDllDialog) public: virtual BOOL PreTranslateMessage( MSG* pMsg ); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CDllDialog ) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; In another project I want to derive another dialog from that dialog like: class CDLG_AppSelect : public CDllDialog { public: CDLG_AppSelect(CWnd* pParent = NULL); // Dialog Data //{{AFX_DATA(CDLG_AppSelect) enum { IDD = IDD_LOGINAPP_DIALOG }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDLG_AppSelect) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: CLD_Button m_btnCancel; CLD_Static m_statDlgTitle; void CreateControls(); // Generated message map functions //{{AFX_MSG(CDLG_AppSelect) virtual BOOL OnInitDialog(); afx_msg virtual int OnPressCancel(); afx_msg virtual int OnStartApplication(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; The error I got is: DLG_AppSelect.obj : error LNK2019: unresolved external symbol "protected: static struct AFX_MSGMAP const CDllDialog::messageMap" (?messageMap@CDllDialog@@1UAFX_MSGMAP@@B) referenced in function "protected: static struct AFX_MSGMAP const * __cdecl C DLG_AppSelect::_GetBaseMessageMap(void)" (?_GetBaseMessageMap@CDLG_AppSelect@@KAPBUAFX_MSGMAP@@XZ) So it looks it has something to do with the DECLARE_MESSAGE_MAP macro or something... Does anyone know how to solve this problem? Thanks for any info you can provide Davy

    P 1 Reply Last reply
    0
    • G GDavy

      I got a linking problem. I think it has something to do with MFC and such but I`m not sure.. The problem is as follows: I made a .dll file and in it is a class derived from CDialog, something like: #ifdef __DLL_BUILD__ #define LD_DECSPEC __declspec(dllexport) #else #define LD_DECSPEC __declspec(dllimport) #endif class LD_DECSPEC CDllDialog : public CDialog { public: CDllDialog( CWnd* pParent = NULL ); CDllDialog( UINT nIDD, CWnd* pParent = NULL ); virtual ~CDllDialog(); // Dialog Data //{{AFX_DATA(CDllDialog ) // NOTE: the ClassWizard will add data members here //}}AFX_DATA enum{ ID_DLG_LOGOUT = 200 }; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDllDialog) public: virtual BOOL PreTranslateMessage( MSG* pMsg ); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(CDllDialog ) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; In another project I want to derive another dialog from that dialog like: class CDLG_AppSelect : public CDllDialog { public: CDLG_AppSelect(CWnd* pParent = NULL); // Dialog Data //{{AFX_DATA(CDLG_AppSelect) enum { IDD = IDD_LOGINAPP_DIALOG }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CDLG_AppSelect) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: CLD_Button m_btnCancel; CLD_Static m_statDlgTitle; void CreateControls(); // Generated message map functions //{{AFX_MSG(CDLG_AppSelect) virtual BOOL OnInitDialog(); afx_msg virtual int OnPressCancel(); afx_msg virtual int OnStartApplication(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; The error I got is: DLG_AppSelect.obj : error LNK2019: unresolved external symbol "protected: static struct AFX_MSGMAP const CDllDialog::messageMap" (?messageMap@CDllDialog@@1UAFX_MSGMAP@@B) referenced in function "protected: static struct AFX_MSGMAP const * __cdecl C DLG_AppSelect::_GetBaseMessageMap(void)" (?_GetBaseMessageMap@CDLG_AppSelect@@KAPBUAFX_MSGMAP@@XZ) So it looks it has something to do with the DECLARE_MESSAGE_MAP macro or something... Does anyone know how to solve this problem? Thanks for any info you can provide Davy

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      You forget this combination in one of file,

      BEGIN_MESSAGE_MAP(CMyDlg, CBaseDlg)
      END_MESSAGE_MAP()

      Prasad Notifier using ATL | Operator new[],delete[][^]

      G 1 Reply Last reply
      0
      • P prasad_som

        You forget this combination in one of file,

        BEGIN_MESSAGE_MAP(CMyDlg, CBaseDlg)
        END_MESSAGE_MAP()

        Prasad Notifier using ATL | Operator new[],delete[][^]

        G Offline
        G Offline
        GDavy
        wrote on last edited by
        #3

        no, both .cpp files contain the BEGIN_MESSAGE_MAP -- END_MESSAGE_MAP block. The problem must lie somewhere else. Thanks for you input anyway. Davy

        P 1 Reply Last reply
        0
        • G GDavy

          no, both .cpp files contain the BEGIN_MESSAGE_MAP -- END_MESSAGE_MAP block. The problem must lie somewhere else. Thanks for you input anyway. Davy

          P Offline
          P Offline
          prasad_som
          wrote on last edited by
          #4

          GDavy wrote:

          BEGIN_MESSAGE_MAP -- END_MESSAGE_MAP block.

          Can you show how you have used in both cpp?

          Prasad Notifier using ATL | Operator new[],delete[][^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups