Reputation: 346
I was trying to implement a protocol stack using Protocol Layer Design Pattern : http://www.eventhelix.com/realtimemantra/patterncatalog/protocol_layer.htm
In our project,I have all the layers as separate dlls. The layers that i have are:
Application Layer dll
LLC Layer dll
MAC Layer dll
Physical Layer dll
I have another project in the same solution which implements the Design Pattern and has the implementations of the General functionalities of a protocol Layer. All my layers are inheriting from the Protocol Layer Base class. The dependency between projects is as follows: Protocol Layer Design Pattern dll: No dependency Physical Layer dll: Protocol Design Pattern dll MAC Layer dll: Protocol Design Pattern dll and Physical Layer dll LLC Layer dll: Protocol Design Pattern dll and MAC Layer dll Application Layer dll: Protocol Design Pattern dll and LLC Layer dll
Based on the design pattern, each of our layer has pointers to the layer above and below it. And the flow that we designed is like: In application layer constructor we create an object of LLC Layer then LLC Layer creates Mac layer and MAC layer inturn creates physical Layer. They all are linked using pointers.
My Protocol Design Pattern project dll and Physical Layer dll builds properly. But other dll builds are giving linker error. Saying unresolved externals to the constructor of the underlying layer. These are the errors which i am getting.
==================================
- 1>phLayer.obj : error LNK2019: unresolved external symbol "public:
virtual __thiscall CProtocolLayer::~CProtocolLayer(void)"
(??1CProtocolLayer@@UAE@XZ) referenced in function
__unwindfunclet$??0CPhysicalLayer@@QAE@PAVCProtocolLayer@@@Z$0 1>phLayer.obj : error LNK2019: unresolved external symbol "public:
__thiscall CReceiveProtocolHandler::CReceiveProtocolHandler(class CProtocolLayer *)"
(??0CReceiveProtocolHandler@@QAE@PAVCProtocolLayer@@@Z) referenced in function "public: __thiscall CPhysicalLayer::CPhysicalLayer(class CProtocolLayer *)" (??0CPhysicalLayer@@QAE@PAVCProtocolLayer@@@Z) 1>phLayer.obj : error LNK2019: unresolved external symbol "public: __thiscall CTransmitProtocolHandler::CTransmitProtocolHandler(class CProtocolLayer *)"
(??0CTransmitProtocolHandler@@QAE@PAVCProtocolLayer@@@Z) referenced in function "public: __thiscall CPhysicalLayer::CPhysicalLayer(class CProtocolLayer *)" (??0CPhysicalLayer@@QAE@PAVCProtocolLayer@@@Z)
1>phLayer.obj : error LNK2019: unresolved external symbol "public:
__thiscall CProtocolLayer::CProtocolLayer(class CProtocolLayer *,class CProtocolLayer *)" (??0CProtocolLayer@@QAE@PAV0@0@Z) referenced in function "public: __thiscall
CPhysicalLayer::CPhysicalLayer(class CProtocolLayer *)"
(??0CPhysicalLayer@@QAE@PAVCProtocolLayer@@@Z) 1>phLayer.obj : error LNK2019: unresolved external symbol "public: int __thiscall
CProtocolPacket::getBodyLength(void)"
(?getBodyLength@CProtocolPacket@@QAEHXZ) referenced in function
"public: virtual void __thiscall CPhysicalLayer::Data_req(class
CProtocolPacket *)"
(?Data_req@CPhysicalLayer@@UAEXPAVCProtocolPacket@@@Z) 1>phLayer.obj : error LNK2019: unresolved external symbol "public: void __thiscall CReceiveProtocolHandler::Handle_Receive(class CProtocolPacket *)"
(?Handle_Receive@CReceiveProtocolHandler@@QAEXPAVCProtocolPacket@@@Z) referenced in function "private: void __thiscall
CPhysicalLayer::dataRead(void)" (?dataRead@CPhysicalLayer@@AAEXXZ)
1>phLayer.obj : error LNK2019: unresolved external symbol "public:
void __thiscall CProtocolPacket::AddTrailer(int,char *)"
(?AddTrailer@CProtocolPacket@@QAEXHPAD@Z) referenced in function
"private: class CProtocolPacket __thiscall
CPhysicalLayer::convertToProtocolPacket(class
std::basic_string,class
std::allocator >)"
(?convertToProtocolPacket@CPhysicalLayer@@AAE?AVCProtocolPacket@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 1>phLayer.obj : error LNK2019: unresolved external symbol "public:
void __thiscall CProtocolPacket::AddHeader(int,char *)"
(?AddHeader@CProtocolPacket@@QAEXHPAD@Z) referenced in function
"private: class CProtocolPacket __thiscall
CPhysicalLayer::convertToProtocolPacket(class
std::basic_string,class
std::allocator >)"
(?convertToProtocolPacket@CPhysicalLayer@@AAE?AVCProtocolPacket@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
Upvotes: 1
Views: 201
Reputation: 501
How are you building the exe? I see that, you are facing only linker issues. Either you must be linking in the wrong order or there must be something, which went wrong. Try to link them in a correct order. This should solve the problem. If not, please provide more information.
Upvotes: 1