How do I include a header as a result of a linker error?

I have two pretty unrelated cpp files, call them simplify.cpp

and migrate.cpp

and and a header file server.h

from another library.

When I try to include server.h

in simplify.cpp

, I get the linker error LNK2001 unresolved external symbol in both cpp files.

I have verified that the symbol it refers to is indeed defined in the library and it is even used elsewhere. This is something like:

SomeObject::SetValue( const std::shared_ptr<Value>& value )

      

which overrides a base class implementation that does nothing.

I'm not even sure if any of them are even relavant, but some more info. The base class implementation is defined in its header (empty curly braces only), and in the SomeObject

. Inheritance is pretty deep and includes some patterns, but this has never been a problem.

Does anyone know what is the reason for this? And why does this cause a link error in another file that I am not even touching?

I am using VS2012.

+3


source to share


1 answer


The reason for the linker error is because the header file states that

"there is a function SomeObject::SetValue( const std::shared_ptr<Value>& value )

somewhere"



but the linker cannot find the definition of this function. If it is indeed defined in the same library you are working with, check the syntax of everything in your definition. Perhaps this is due to a typo.

0


source







All Articles