プロトコルレイヤーデザインパターンを使用してプロトコルスタックを実装しようとしていました:http: //www.eventhelix.com/realtimemantra/patterncatalog/protocol_layer.htm
私たちのプロジェクトでは、すべてのレイヤーを個別のdllとして使用しています。私が持っているレイヤーは次のとおりです。
アプリケーション層dll
LLCレイヤーdll
MACレイヤーdll
物理層dll
同じソリューションに、デザインパターンを実装し、プロトコルレイヤーの一般的な機能を実装した別のプロジェクトがあります。私のすべてのレイヤーは、ProtocolLayerBaseクラスから継承しています。プロジェクト間の依存関係は次のとおりです。プロトコルレイヤーデザインパターンdll:依存関係なし物理レイヤーdll:プロトコルデザインパターンdll MACレイヤーdll:プロトコルデザインパターンdllと物理レイヤーdll LLCレイヤーdll:プロトコルデザインパターンdllとMACレイヤーdllアプリケーションレイヤーdll:プロトコルデザインパターンdllおよびLLCレイヤーdll
デザインパターンに基づいて、各レイヤーにはその上下のレイヤーへのポインターがあります。そして、私たちが設計したフローは次のようになります。アプリケーション層コンストラクターでLLC層のオブジェクトを作成し、次にLLC層がMac層を作成し、次にMAC層が物理層を作成します。それらはすべてポインタを使用してリンクされています。
プロトコルデザインパターンプロジェクトdllと物理層dllが正しくビルドされます。しかし、他のdllビルドはリンカーエラーを出します。基になるレイヤーのコンストラクターに未解決の外部を言います。これらは私が得ているエラーです。
==================================
- 1> phLayer.obj:エラーLNK2019:未解決の外部シンボル "public:
virtual __thiscall CProtocolLayer ::〜CProtocolLayer(void)"
(?? 1CProtocolLayer @@ UAE @ XZ)関数
__unwindfunclet $ ?? 0CPhysicalLayer @@ QAE @ PAVCProtocolLayer @ @@ Z $ 0 1> phLayer.obj:エラーLNK2019:未解決の外部シンボル "public:
__thiscall CReceiveProtocolHandler :: CReceiveProtocolHandler(class CProtocolLayer *)"
(?? 0CReceiveProtocolHandler @@ QAE @ PAVCProtocolLayer @@@ Z)関数 "public: __thiscall CPhysicalLayer :: CPhysicalLayer(class CProtocolLayer *) "(?? 0CPhysicalLayer @@ QAE @ PAVCProtocolLayer @@@ Z)1> phLayer.obj:エラーLNK2019:未解決の外部シンボル" public:__thiscall CTransmitProtocolHandler ::CTransmitProtocolHandler(class CProtocolLayer *) "
(?? 0CTransmitProtocolHandler @@ QAE @ PAVCProtocolLayer @@@ Z)関数 "public:__thiscall CPhysicalLayer :: CPhysicalLayer(class CProtocolLayer *)"(?? 0CPhysicalLayer @@ QAE @ PAVCProtocolLayer @@@ Z)
1>phLayer.objで参照:エラーLNK2019:未解決の外部シンボル "public:
__ thiscall CProtocolLayer :: CProtocolLayer(class CProtocolLayer *、class CProtocolLayer *)"(?? 0CProtocolLayer @@ QAE @ PAV0 @ 0 @ Z)関数 "public:__
thiscall CPhysicalLayer::CPhysicalLayerで参照(class CProtocolLayer *) "
(?? 0CPhysicalLayer @@ QAE @ PAVCProtocolLayer @@@ Z)1> phLayer.obj:エラーLNK2019:未解決の外部シンボル" public:int __thiscall
CProtocolPacket :: getBodyLength(void) "
(?getBodyLength @ CProtocolPacket @@ QAEHXZ)関数で参照されます
"public:virtual void __thiscall CPhysicalLayer :: Data_req(class
CProtocolPacket *)"
(?Data_req @ CPhysicalLayer @@ UAEXPAVCProtocolPacket @@@ Z)1> phLayer.obj:エラーLNK2019:未解決の外部シンボル "public:void __thiscall CReceiveProtocolHandler :: Handle_ (class CProtocolPacket *) "
(?Handle_Receive @ CReceiveProtocolHandler @@ QAEXPAVCProtocolPacket @@@ Z)関数" private:void __thiscall
CPhysicalLayer :: dataRead(void) "(?dataRead @ CPhysicalLayer @@ AAEXXZ)
1> phLayer.obj:エラーLNK2019:未解決の外部シンボル "public:
void __thiscall CProtocolPacket :: AddTrailer(int、char *)"
(?AddTrailer @ CProtocolPacket @@ QAEXHPAD @ Z)関数
"private:クラス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:エラーLNK2019:未解決の外部シンボル "public:
void __thiscall CProtocolPacket :: AddHeader(int、char *)"
(?AddHeader @ CProtocolPacket @@ QAEXHPAD @ Z )関数
"private:class CProtocolPacket __thiscall
CPhysicalLayer :: convertToProtocolPacket(class
std :: basic_string、class
std :: allocator>)"
(?convertToProtocolPacket @ CPhysicalLayer @@ AAE?AVCProtocolPacket @@ V?$ basic_string @ DU? @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ Z)