error LNK2019 problem

N

Nicros

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
 
J

John Harrison

Nicros said:
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
 
H

Howard

John Harrison said:
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
 
N

Nicros

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);
}
 
J

John Harrison

Nicros said:
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
 
H

Howard

John Harrison said:
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
 
J

John Harrison

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top