I load a GetInstance function from a C++ dll with GetProcAddress to my base code and get some Unresolved external symbol errors:
error LNK2019: unresolved external symbol "_declspec(dllimport) public: unsigned int _thiscall RegTestAPI::CTestmode_Sle70::SetMSfr(unsigned int,unsigned short,char *)" (_imp?SetMSfr@CTestmode_Sle70@RegTestAPI@@QAEIIGPAD@Z) referenced in function "int __cdecl SetUserDescriptor(unsigned char,unsigned int,unsigned int)" (?SetUserDescriptor@@YAHEII@Z)
DLL code
header
extern "C" _declspec(dllexport) CTestmode* GetInstance();
source
CTestmode *cTestmode;
extern "C" _declspec(dllexport) CTestmode* GetInstance()
{
cTestmode = CTestmode::Instance();
return cTestmode;
}
...
// in header
static CTestmode* Instance();
...
static CTestmode* m_pInstance;
// in source
CTestmode* CTestmode::Instance()
{
if(m_pInstance == NULL)
{
m_pInstance = new CTestmode();
}
return m_pInstance;
}
Tool code
typedef CTestmode* (*CTestModeInstance)(void);
CTestmode *pMyTM;
...
HMODULE handleTestmode;
handleTestmode = LoadLibrary("Testmode.dll");
CTestModeInstance cTestModeInstance = (CTestModeInstance)GetProcAddress(handleTestmode, "GetInstance");
pMyTM = (cTestModeInstance)();
My idea is that something with the calling conventions are wrong (look at the error message -> __thiscall and __cdecl Hint: both projects are set to __cdecl (/Gd)) ?!
Any ideas why this won't work?
Thank you in advance!
greets
SetUserDescriptor
, and declaration and definition ofCTestmode_Sle70::SetMSfr
. – Dialecticus