gpt4 book ai didi

c++ - 当用户定义的 dll 引用另一个用户定义的 dll 时出现链接器错误

转载 作者:太空宇宙 更新时间:2023-11-04 11:58:45 25 4
gpt4 key购买 nike

我试图使用协议(protocol)层设计模式来实现协议(protocol)栈: http://www.eventhelix.com/realtimemantra/patterncatalog/protocol_layer.htm

在我们的项目中,我将所有层都作为单独的 dll。我拥有的图层是:

  1. 应用层dll

  2. LLC层dll

  3. MAC 层 dll

  4. 物理层dll

我在同一个解决方案中有另一个项目实现了设计模式和具有协议(protocol)层的一般功能的实现。我所有的层都继承自协议(protocol)层基类。之间的依赖项目如下:协议(protocol)层设计模式 dll:无依赖物理层dll:协议(protocol)设计模式dllMAC层dll:协议(protocol)设计模式dll和物理层dllLLC层dll:协议(protocol)设计模式dll和MAC层dll应用层dll:协议(protocol)设计模式dll和LLC层dll

基于设计模式,我们的每一层都有指向其上下层的指针。我们设计的流程是这样的:在应用层构造函数中,我们创建了一个对象 LLC 层然后 LLC 层创建 Mac 层,MAC 层又创建物理层。它们都是相连的使用指针。

我的协议(protocol)设计模式项目 dll 和物理层 dll 构建正确。但是其他 dll 构建正在提供链接器错误。对底层的构造函数说 Unresolved external 问题。这些是我遇到的错误。

==================================

  1. 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)

最佳答案

你是如何构建 exe 的?我看到了,您只面临链接器问题。您必须以错误的顺序链接,或者一定有什么地方出错了。尝试以正确的顺序链接它们。这应该可以解决问题。如果没有,请提供更多信息。

关于c++ - 当用户定义的 dll 引用另一个用户定义的 dll 时出现链接器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15049255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com