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. unresolved external symbol

unresolved external symbol

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestionannouncement
5 Posts 4 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    My class h file is

    class CScale : public CStatic
    {
    // Construction
    public:
    CScale();

    // Attributes
    public:

    // Operations
    public:

    // Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CGraphCtrl)
    public:

    protected:
    
    protected:
    virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT\* pResult);
    virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
    //}}AFX\_VIRTUAL
    

    // Implementation
    public:
    CFont m_font;
    COLORREF *BC, BGC;

    // Generated message map functions
    

    protected:
    //{{AFX_MSG(CScale)
    afx_msg BOOL OnPaint(CDC* pDC);
    //}}AFX_MSG

    DECLARE\_MESSAGE\_MAP()
    

    };

    I have all the function bodies in the cpp file. When I compile I get:

    GraphCtrl.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CScale::GetMessageMap(void)const " (?GetMessageMap@CScale@@MBEPBUAFX_MSGMAP@@XZ)
    Release/RunCadMFCDLL.dll : fatal error LNK1120: 1 unresolved externals

    :confused: thanks for helping, sb

    D V B 3 Replies Last reply
    0
    • N ns

      My class h file is

      class CScale : public CStatic
      {
      // Construction
      public:
      CScale();

      // Attributes
      public:

      // Operations
      public:

      // Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CGraphCtrl)
      public:

      protected:
      
      protected:
      virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT\* pResult);
      virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
      virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
      //}}AFX\_VIRTUAL
      

      // Implementation
      public:
      CFont m_font;
      COLORREF *BC, BGC;

      // Generated message map functions
      

      protected:
      //{{AFX_MSG(CScale)
      afx_msg BOOL OnPaint(CDC* pDC);
      //}}AFX_MSG

      DECLARE\_MESSAGE\_MAP()
      

      };

      I have all the function bodies in the cpp file. When I compile I get:

      GraphCtrl.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CScale::GetMessageMap(void)const " (?GetMessageMap@CScale@@MBEPBUAFX_MSGMAP@@XZ)
      Release/RunCadMFCDLL.dll : fatal error LNK1120: 1 unresolved externals

      :confused: thanks for helping, sb

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Do you have BEGIN_MESSAGE_MAP() in your class' .cpp file?


      "The largest fire starts but with the smallest spark." - David Crow

      "Judge not by the eye but by the heart." - Native American Proverb

      N 1 Reply Last reply
      0
      • N ns

        My class h file is

        class CScale : public CStatic
        {
        // Construction
        public:
        CScale();

        // Attributes
        public:

        // Operations
        public:

        // Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CGraphCtrl)
        public:

        protected:
        
        protected:
        virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT\* pResult);
        virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
        virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
        //}}AFX\_VIRTUAL
        

        // Implementation
        public:
        CFont m_font;
        COLORREF *BC, BGC;

        // Generated message map functions
        

        protected:
        //{{AFX_MSG(CScale)
        afx_msg BOOL OnPaint(CDC* pDC);
        //}}AFX_MSG

        DECLARE\_MESSAGE\_MAP()
        

        };

        I have all the function bodies in the cpp file. When I compile I get:

        GraphCtrl.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CScale::GetMessageMap(void)const " (?GetMessageMap@CScale@@MBEPBUAFX_MSGMAP@@XZ)
        Release/RunCadMFCDLL.dll : fatal error LNK1120: 1 unresolved externals

        :confused: thanks for helping, sb

        V Offline
        V Offline
        Viorel
        wrote on last edited by
        #3

        It seems that for your CScale control there is no corresponding BEGIN_MESSAGE_MAP/END_MESSAGE_MAP zone (created by Class Wizard) in CPP file. Open the CPP file where the implementation of CScale class is provided, and check if there is a BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macros here, something like this:

        BEGIN_MESSAGE_MAP(CScale, CStatic)
            // . . .
        END_MESSAGE_MAP()
        

        In addition, check if your CPP file is included in the project, i.e. is listed in the Solution Explorer panel, and is not excluded from build process. Hope it helps.

        1 Reply Last reply
        0
        • D David Crow

          Do you have BEGIN_MESSAGE_MAP() in your class' .cpp file?


          "The largest fire starts but with the smallest spark." - David Crow

          "Judge not by the eye but by the heart." - Native American Proverb

          N Offline
          N Offline
          ns
          wrote on last edited by
          #4

          Duh!:doh: I made the cpp file from scratch (the class wizard didn't make it), and I did not even think about the message map section needing to be in there (though I know its always there. thanks to both of you - you diagnosed it right away sb

          1 Reply Last reply
          0
          • N ns

            My class h file is

            class CScale : public CStatic
            {
            // Construction
            public:
            CScale();

            // Attributes
            public:

            // Operations
            public:

            // Overrides
            // ClassWizard generated virtual function overrides
            //{{AFX_VIRTUAL(CGraphCtrl)
            public:

            protected:
            
            protected:
            virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT\* pResult);
            virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
            virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
            //}}AFX\_VIRTUAL
            

            // Implementation
            public:
            CFont m_font;
            COLORREF *BC, BGC;

            // Generated message map functions
            

            protected:
            //{{AFX_MSG(CScale)
            afx_msg BOOL OnPaint(CDC* pDC);
            //}}AFX_MSG

            DECLARE\_MESSAGE\_MAP()
            

            };

            I have all the function bodies in the cpp file. When I compile I get:

            GraphCtrl.obj : error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall CScale::GetMessageMap(void)const " (?GetMessageMap@CScale@@MBEPBUAFX_MSGMAP@@XZ)
            Release/RunCadMFCDLL.dll : fatal error LNK1120: 1 unresolved externals

            :confused: thanks for helping, sb

            B Offline
            B Offline
            Blake Miller
            wrote on last edited by
            #5

            What the others have said, and also, if you want ClassWizard to work correctly, you need to make all this stuff match ... // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CGraphCtrl) should be // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CScale) Be careful what you cut and paste - don't forget the edit! I've seen better runs in my shorts! - Patches O'Houlihan

            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