微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

错误 LNK2019 未解析的外部符号 - 在一个 DLL 中调用多个类

如何解决错误 LNK2019 未解析的外部符号 - 在一个 DLL 中调用多个类

我有一个包含封装类的 DLL,我们称其为 A 类,它运行良好。现在我想在同一个 DLL 中添加一个类; A 类调用 B 类。这会导致链接错误(但它们在同一个 DLL 中)。如果我删除 B 类,一切正常,这些类或函数都不会从 DLL 外部调用!!!

/******** DLL ********/


 #ifndef ENGD3D12_H
#define ENGD3D12_H
class cpuOP;

class EngD3D12 : public IRenderDevice,public RendererAttributes
{
public:
    EngD3D12(HINSTANCE hDll);
    ~EngD3D12(void);

cpuOP *cpuOP;



}
#endif
///////////////////////////////////////
CPP FILE
EngD3D12::EngD3D12(HINSTANCE hDLL) 
{
    cpuOP = new cpuOP(); // err
    cpuOP->GetcpuInfo();    //err
    this->m_hDLL = hDLL;
    m4xmsaaState = false;
    m4xmsaaQuality = 0;
    mCurrentBackBuffer = 0;
    mCurrentFence = 0;
    mBackBufferFormat = dxgi_FORMAT_R8G8B8A8_UnorM;
    mDepthStencilFormat = dxgi_FORMAT_D24_UnorM_S8_UINT;
    m_hFenceEvent = CreateEventExW(nullptr,false,EVENT_ALL_ACCESS);
}

//////////////////////////////////////////////
cpuOP.H
#ifndef cpuOP_H
#define cpuOP_H


 class cpuOP
{
    
    public :
        
        typedef struct cpuINFO_Type {
            bool bSSE;
            bool bSSE2;
            bool bSSE3;
            bool bSSSE3;
            bool bSSE4_2;
            bool bSSE4_1;
            bool bAVX;
            bool bOSEnabledAVX;
            bool b3DNow;
            bool bMMX;
            char name[48];
            bool bExt;
            bool bMmxex;
            bool b3DNowEx;
            char vendor[13];
            
        }  cpuINFO;
    cpuOP();
    ~cpuOP();
    cpuINFO GetcpuInfo();
    
    bool OSSupportSSEE();
    void GetcpuName(char*,int,const char*);
};
 
#endif

///////////////////////////////////////
//cpuOP.cpp
cpuOP::cpuOP()
{

}
cpuOP::cpuINFO cpuOP::GetcpuInfo()
{}
/******** DLL ********/

> Severity  Code    Description Project File    Line    Suppression State
> Error LNK2019 unresolved external symbol "public: __thiscall
> cpuOP::cpuOP(void)" (??0cpuOP@@QAE@XZ) referenced in function "public:
> __thiscall EngD3D12::EngD3D12(struct HINSTANCE__ *)" (??0EngD3D12@@QAE@PAUHINSTANCE__@@@Z)     Error  LNK2019 unresolved
> external symbol "public: struct cpuOP::cpuINFO_Type __thiscall
> cpuOP::GetcpuInfo(void)" (?GetcpuInfo@cpuOP@@QAE?AUcpuINFO_Type@1@XZ)
> referenced in function "public: __thiscall EngD3D12::EngD3D12(struct
> HINSTANCE__ *)" (??0EngD3D12@@QAE@PAUHINSTANCE__@@@Z)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?