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. No Idea why the linker is giving error

No Idea why the linker is giving error

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studiodebugginghelp
7 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.
  • L Offline
    L Offline
    Larry Mills Sr
    wrote on last edited by
    #1

    In my PropertyPage header I have this declaration: #include "CookItDBDoc.h" // CSpecial2Page1 dialog class CSpecial2Page1 : public CBCGPPropertyPage {      DECLARE_DYNAMIC(CSpecial2Page1) public:      CSpecial2Page1();      //CWnd* pParent = NULL, int nDlg = 0, CString csDlgName = "");   // standard constructor      virtual ~CSpecial2Page1();      void RetFromGetSpecialMealDlg(CString csFileName); // Attributes public:      CCookItDBDoc* GetDocument() const; ... } ============> in .cpp file <======================== void CSpecial2Page1::RetFromGetSpecialMealDlg(CString csFileName)      {      m_csFileName = csFileName;      FileReadCatMenuXML(m_csFileName);      FileReadSpecialMenuXML(m_cMenuData.m_csFullFilePath);      CSpecial2* pPS = (CSpecial2*)GetParent();      pPS->SetSpecial(m_cSpecialData);      pPS->SetMenuData(m_cMenuData);      SetDlgItemText(IDC_SELDRINKS,m_cSpecialData.m_csSpecialOccassionName);      FileReadDrinkMenuXML(m_cSpecialData.m_csDrinkFilePath);      InsertItemsDrink();      GetDocument()->OnNewSpecialDrink(m_vDrink, m_cSpecialData.m_csSpecialOccassionName);      } the error is this: 1>Linking... 1>Special2Page1.obj : error LNK2019: unresolved external symbol "public: class CCookItDBDoc * __thiscall CSpecial2Page1::GetDocument(void)const " (?GetDocument@CSpecial2Page1@@QBEPAVCCookItDBDoc@@XZ) referenced in function "public: void __thiscall CSpecial2Page1::RetFromGetSpecialMealDlg(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >)" (?RetFromGetSpecialMealDlg@CSpecial2Page1@@QAEXV?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) 1>C:\Users\Larry A Mills Sr\Documents\Visual Studio 2008\Projects\CookItDB\Debug\CookItDB.exe : fatal error LNK1120: 1 unresolved externals 1>Build log was saved at "file://c:\Users\Larry A Mills Sr\Documents\Visual Studio 2008\Projects\CookItDB\CookItDB\Debug\BuildLog.htm" 1>CookItDB - 2 error(s), 0 warning(s) I thought maybe I had mispelled something so I checked: in Doc header:      void OnNewSpecialDrink(CDrinkDataVec vData,

    K 1 Reply Last reply
    0
    • L Larry Mills Sr

      In my PropertyPage header I have this declaration: #include "CookItDBDoc.h" // CSpecial2Page1 dialog class CSpecial2Page1 : public CBCGPPropertyPage {      DECLARE_DYNAMIC(CSpecial2Page1) public:      CSpecial2Page1();      //CWnd* pParent = NULL, int nDlg = 0, CString csDlgName = "");   // standard constructor      virtual ~CSpecial2Page1();      void RetFromGetSpecialMealDlg(CString csFileName); // Attributes public:      CCookItDBDoc* GetDocument() const; ... } ============> in .cpp file <======================== void CSpecial2Page1::RetFromGetSpecialMealDlg(CString csFileName)      {      m_csFileName = csFileName;      FileReadCatMenuXML(m_csFileName);      FileReadSpecialMenuXML(m_cMenuData.m_csFullFilePath);      CSpecial2* pPS = (CSpecial2*)GetParent();      pPS->SetSpecial(m_cSpecialData);      pPS->SetMenuData(m_cMenuData);      SetDlgItemText(IDC_SELDRINKS,m_cSpecialData.m_csSpecialOccassionName);      FileReadDrinkMenuXML(m_cSpecialData.m_csDrinkFilePath);      InsertItemsDrink();      GetDocument()->OnNewSpecialDrink(m_vDrink, m_cSpecialData.m_csSpecialOccassionName);      } the error is this: 1>Linking... 1>Special2Page1.obj : error LNK2019: unresolved external symbol "public: class CCookItDBDoc * __thiscall CSpecial2Page1::GetDocument(void)const " (?GetDocument@CSpecial2Page1@@QBEPAVCCookItDBDoc@@XZ) referenced in function "public: void __thiscall CSpecial2Page1::RetFromGetSpecialMealDlg(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >)" (?RetFromGetSpecialMealDlg@CSpecial2Page1@@QAEXV?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z) 1>C:\Users\Larry A Mills Sr\Documents\Visual Studio 2008\Projects\CookItDB\Debug\CookItDB.exe : fatal error LNK1120: 1 unresolved externals 1>Build log was saved at "file://c:\Users\Larry A Mills Sr\Documents\Visual Studio 2008\Projects\CookItDB\CookItDB\Debug\BuildLog.htm" 1>CookItDB - 2 error(s), 0 warning(s) I thought maybe I had mispelled something so I checked: in Doc header:      void OnNewSpecialDrink(CDrinkDataVec vData,

      K Offline
      K Offline
      krmed
      wrote on last edited by
      #2

      Your CSpecial2Page1 is apparently derived from a class you derived from CPropertyPage, and that class does not have a GetDocument method. Unless you've defined that method in your CBCGPPropertyPage class, it doesn't exist and that's why you get the error.

      Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

      L 1 Reply Last reply
      0
      • K krmed

        Your CSpecial2Page1 is apparently derived from a class you derived from CPropertyPage, and that class does not have a GetDocument method. Unless you've defined that method in your CBCGPPropertyPage class, it doesn't exist and that's why you get the error.

        Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

        L Offline
        L Offline
        Larry Mills Sr
        wrote on last edited by
        #3

        I thought by my putting the #include CCookItDBDoc.h in the prpopertyPage header that I would be able to jump to a function(Non-static) within the CCookItDBDoc class. I   guess you can't do it that way. How would you do it?

        A C++ programming language novice, but striving to learn

        K 1 Reply Last reply
        0
        • L Larry Mills Sr

          I thought by my putting the #include CCookItDBDoc.h in the prpopertyPage header that I would be able to jump to a function(Non-static) within the CCookItDBDoc class. I   guess you can't do it that way. How would you do it?

          A C++ programming language novice, but striving to learn

          K Offline
          K Offline
          krmed
          wrote on last edited by
          #4

          Including the header only provides the declaration of the class. Non-static members do not actually exist except within an instance of the class itself. You probably already have a document instance (CYourAppDoc) somwhere, so you need to provide a pointer to that existing instance in order to use its methods. The existing instance contains all of the variables (with their appropriate values), so if you were to create a new instance in your propert page class, it would be a different instance with different values. One way this is done with a dialog box would be to have a button that you click to create the dialog and the handler for that button is in the document. The dialog header file might contain something like

          CYourAppDoc* m_pMyDocPtr;

          Then when the button is clicked the handler (in the doc class) might have something like this:

          CMyDialog myDlg;
          myDlg.m_pMyDocPtr = this;
          myDlg.DoModal()

          Now in the dialog, you can access the doc data and methods by using

          m_pDocPtr->DocFunction1();

          Hope that helps.

          Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

          L 1 Reply Last reply
          0
          • K krmed

            Including the header only provides the declaration of the class. Non-static members do not actually exist except within an instance of the class itself. You probably already have a document instance (CYourAppDoc) somwhere, so you need to provide a pointer to that existing instance in order to use its methods. The existing instance contains all of the variables (with their appropriate values), so if you were to create a new instance in your propert page class, it would be a different instance with different values. One way this is done with a dialog box would be to have a button that you click to create the dialog and the handler for that button is in the document. The dialog header file might contain something like

            CYourAppDoc* m_pMyDocPtr;

            Then when the button is clicked the handler (in the doc class) might have something like this:

            CMyDialog myDlg;
            myDlg.m_pMyDocPtr = this;
            myDlg.DoModal()

            Now in the dialog, you can access the doc data and methods by using

            m_pDocPtr->DocFunction1();

            Hope that helps.

            Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

            L Offline
            L Offline
            Larry Mills Sr
            wrote on last edited by
            #5

            Yes, I know that, but how would I do that with a CDocument and a CPropertyPage?

            A C++ programming language novice, but striving to learn

            K 1 Reply Last reply
            0
            • L Larry Mills Sr

              Yes, I know that, but how would I do that with a CDocument and a CPropertyPage?

              A C++ programming language novice, but striving to learn

              K Offline
              K Offline
              krmed
              wrote on last edited by
              #6

              The principal is still the same - pass a pointer to your document into your property pages. You may want to pass it to the property sheet and then have the sheet pass it to the pages. If you create your pages/sheet from a view, your view probably also has a pointer to the document. Good luck.

              Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

              L 1 Reply Last reply
              0
              • K krmed

                The principal is still the same - pass a pointer to your document into your property pages. You may want to pass it to the property sheet and then have the sheet pass it to the pages. If you create your pages/sheet from a view, your view probably also has a pointer to the document. Good luck.

                Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                L Offline
                L Offline
                Larry Mills Sr
                wrote on last edited by
                #7

                Thanks

                A C++ programming language novice, but striving to learn

                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