如何解决错误 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 举报,一经查实,本站将立刻删除。