I have a DLL contains an encapsulated class, let's call it class A, and it works fine. now I want to add another class inside the same DLL; class A call class B. this causes a linking error(but they are inside the same DLL).if I remove class B everything works, None of these classes or functions are being called from outside the 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, 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)