问题描述
我有一个包含封装类的 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 (将#修改为@)