error LNK2019 problem

Discussion in 'C++' started by Nicros, Nov 28, 2005.

  1. Nicros

    Nicros Guest

    Hi,

    I have a simple project, with a main application and a static library.
    I call a function from one of the classes in the static lib, but during
    compile time I get the LNK2019 problem.

    Strange thing is that if I call a different function there is no compile
    error with that one. Both public, both defined in the header and
    implemented in the cpp file.

    I have triple checked that my libraries are linked correctly... all
    other functions and classes are linked just fine... just this one
    function is a problem.

    Any suggestions on what it may be?

    Thanks
    Nicros, Nov 28, 2005
    #1
    1. Advertising

  2. Nicros wrote:
    > Hi,
    >
    > I have a simple project, with a main application and a static library. I
    > call a function from one of the classes in the static lib, but during
    > compile time I get the LNK2019 problem.
    >
    > Strange thing is that if I call a different function there is no compile
    > error with that one. Both public, both defined in the header and
    > implemented in the cpp file.
    >
    > I have triple checked that my libraries are linked correctly... all
    > other functions and classes are linked just fine... just this one
    > function is a problem.
    >
    > Any suggestions on what it may be?
    >
    > Thanks


    Perhaps you have declared one function in the header and implemented a
    different function in the cpp file.

    Why not show us the code? Cut and paste it from your cpp file and header
    file.

    john
    John Harrison, Nov 28, 2005
    #2
    1. Advertising

  3. Nicros

    Howard Guest

    "John Harrison" <> wrote in message
    news:M5zif.6639$...
    > Nicros wrote:
    >> Hi,
    >>
    >> I have a simple project, with a main application and a static library. I
    >> call a function from one of the classes in the static lib, but during
    >> compile time I get the LNK2019 problem.
    >>
    >> Strange thing is that if I call a different function there is no compile
    >> error with that one. Both public, both defined in the header and
    >> implemented in the cpp file.
    >>
    >> I have triple checked that my libraries are linked correctly... all other
    >> functions and classes are linked just fine... just this one function is a
    >> problem.
    >>
    >> Any suggestions on what it may be?
    >>
    >> Thanks

    >
    > Perhaps you have declared one function in the header and implemented a
    > different function in the cpp file.
    >
    > Why not show us the code? Cut and paste it from your cpp file and header
    > file.
    >


    You should also include the text of that link error. Error codes like
    "LNK2019" are specific to your compiler (and possibly even just that version
    of the compiler), and we have no way to know what it means, or to what
    functions or files it is referring.

    -Howard
    Howard, Nov 28, 2005
    #3
  4. Nicros

    Nicros Guest


    >
    >
    > You should also include the text of that link error. Error codes like
    > "LNK2019" are specific to your compiler (and possibly even just that version
    > of the compiler), and we have no way to know what it means, or to what
    > functions or files it is referring.
    >
    > -Howard
    >


    Here is the linker error:
    AutomatonViewer error LNK2019: unresolved external symbol "public: void
    __thiscall CSimulator::StartSimulation(class ATL::CStringT<char,class
    StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > &,class
    ATL::CStringT<char,class StrTraitMFC_DLL<char,class
    ATL::ChTraitsCRT<char> > > &)"
    (?StartSimulation@CSimulator@@QAEXAAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0@Z)
    referenced in function "public: void __thiscall
    CAutomatonViewerDoc::OnSimulationRun(void)"
    (?OnSimulationRun@CAutomatonViewerDoc@@QAEXXZ)


    Here is the function declaration from the header for class CSimulator:
    void StartSimulation(CString& cstrPathInit, CString& cstrPathArchive);

    And from the cpp file:
    void CSimulator::StartSimulation(CString& cstrPathInit, CString&
    cstrPathArchive)
    {

    }

    The call:
    void CAutomatonViewerDoc::OnSimulationRun()
    {
    m_simulator.StartSimulation(m_cstrPathInitFile, m_cstrPathArchive);
    }
    Nicros, Nov 29, 2005
    #4
  5. Nicros wrote:
    >
    >>
    >>
    >> You should also include the text of that link error. Error codes like
    >> "LNK2019" are specific to your compiler (and possibly even just that
    >> version of the compiler), and we have no way to know what it means, or
    >> to what functions or files it is referring.
    >>
    >> -Howard
    >>

    >
    > Here is the linker error:
    > AutomatonViewer error LNK2019: unresolved external symbol "public: void
    > __thiscall CSimulator::StartSimulation(class ATL::CStringT<char,class
    > StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > &,class
    > ATL::CStringT<char,class StrTraitMFC_DLL<char,class
    > ATL::ChTraitsCRT<char> > > &)"
    > (?StartSimulation@CSimulator@@QAEXAAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0@Z)
    > referenced in function "public: void __thiscall
    > CAutomatonViewerDoc::OnSimulationRun(void)"
    > (?OnSimulationRun@CAutomatonViewerDoc@@QAEXXZ)
    >
    >
    > Here is the function declaration from the header for class CSimulator:
    > void StartSimulation(CString& cstrPathInit, CString& cstrPathArchive);
    >
    > And from the cpp file:
    > void CSimulator::StartSimulation(CString& cstrPathInit, CString&
    > cstrPathArchive)
    > {
    >
    > }
    >
    > The call:
    > void CAutomatonViewerDoc::OnSimulationRun()
    > {
    > m_simulator.StartSimulation(m_cstrPathInitFile, m_cstrPathArchive);
    > }



    One posssible explaination, check that the StartSimulation function is
    declared in the public part of the CSimulator class.

    Failing that, I suggest physically deleteing all the object and library
    files and rebuilding your entire project.

    And failing that post the entire code, or put it on a web site and post
    the link.

    john
    John Harrison, Nov 29, 2005
    #5
  6. Nicros

    Howard Guest

    "John Harrison" <> wrote in message
    news:f9Tif.10133$...
    > Nicros wrote:
    >>
    >>>
    >>>
    >>> You should also include the text of that link error. Error codes like
    >>> "LNK2019" are specific to your compiler (and possibly even just that
    >>> version of the compiler), and we have no way to know what it means, or
    >>> to what functions or files it is referring.
    >>>
    >>> -Howard
    >>>

    >>
    >> Here is the linker error:
    >> AutomatonViewer error LNK2019: unresolved external symbol "public: void
    >> __thiscall CSimulator::StartSimulation(class ATL::CStringT<char,class
    >> StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > &,class
    >> ATL::CStringT<char,class StrTraitMFC_DLL<char,class
    >> ATL::ChTraitsCRT<char> > > &)"
    >> (?StartSimulation@CSimulator@@QAEXAAV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@0@Z)
    >> referenced in function "public: void __thiscall
    >> CAutomatonViewerDoc::OnSimulationRun(void)"
    >> (?OnSimulationRun@CAutomatonViewerDoc@@QAEXXZ)
    >>
    >>
    >> Here is the function declaration from the header for class CSimulator:
    >> void StartSimulation(CString& cstrPathInit, CString& cstrPathArchive);
    >>
    >> And from the cpp file:
    >> void CSimulator::StartSimulation(CString& cstrPathInit, CString&
    >> cstrPathArchive)
    >> {
    >>
    >> }
    >>
    >> The call:
    >> void CAutomatonViewerDoc::OnSimulationRun()
    >> {
    >> m_simulator.StartSimulation(m_cstrPathInitFile, m_cstrPathArchive);
    >> }

    >
    >
    > One posssible explaination, check that the StartSimulation function is
    > declared in the public part of the CSimulator class.


    Declaring that as private or protected wouldn't result in a linker error.
    It would result in a compile error.

    A better place to ask might be an MFC newsgroup. It's some project setup
    issue, not anything related to the C++ code itself. There's certainly
    nothing in that code that will tell us for sure what the problem is.
    (Perhaps something related to linking with that ATL namespace?)

    -Howard
    Howard, Nov 29, 2005
    #6
  7. >>
    >>One posssible explaination, check that the StartSimulation function is
    >>declared in the public part of the CSimulator class.

    >
    >
    > Declaring that as private or protected wouldn't result in a linker error.
    > It would result in a compile error.


    Not if CAutomatonViewerDoc was declared a friend of CSimulator. It was
    the best I could think of.

    john
    John Harrison, Nov 29, 2005
    #7
  8. Nicros

    Aleksei_Malkov

    Joined:
    Apr 10, 2008
    Messages:
    1
    Aleksei_Malkov, Apr 10, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sheep
    Replies:
    3
    Views:
    1,250
    Jiangsheng[Microsoft MVP of VC++]
    Aug 4, 2004
  2. Morten Aune Lyrstad

    error LNK2019

    Morten Aune Lyrstad, Aug 26, 2004, in forum: C++
    Replies:
    5
    Views:
    2,009
    Morten Aune Lyrstad
    Aug 27, 2004
  3. f rom
    Replies:
    2
    Views:
    653
    Fredrik Lundh
    Dec 5, 2006
  4. NewsGroup
    Replies:
    3
    Views:
    653
    Michael
    Oct 27, 2006
  5. Trent
    Replies:
    9
    Views:
    605
    Trent
    Jun 29, 2007
Loading...

Share This Page