Original Post
Straight to the point, I have a DLL, inside it functions will be stored that can access classes within the EXE. To do this im guessing that the system must work like this: EXE calls a function inside the DLL to set a pointer DLL sets its pointer to the class(es) EXE then calls (for example) the update function within the DLL DLL does the dirty work, and can call functions within the EXE via this pointer. Im having a few problems compiling the DLL though: engdll.obj : error LNK2001: unresolved external symbol "public: void __thiscall cTestClass::PrintFloat(float *)" (?PrintFloat@cTestClass@@QAEXPAM@Z) engdll.obj : error LNK2001: unresolved external symbol "public: void __thiscall cTestClass::PrintInt(int *)" (?PrintInt@cTestClass@@QAEXPAH@Z) engdll.obj : error LNK2001: unresolved external symbol "public: void __thiscall cTestClass::PrintText(char *)" (?PrintText@cTestClass@@QAEXPAD@Z) Does anyone else have any experience with DLLs, this is my first attempt at making one and i've probably went about this completely the wrong way. Anyways, here is the code i'm using to make the DLL (condensed all the includes so its one file for on here), its not got any practical use, its just a mess about for now: engdll.cpp: engdll.def:
class cTestClass
{
public:
void PrintText(char *l_szText);
void PrintInt(int *l_iNumber);
void PrintFloat(float *l_fNumber);
};
cTestClass *g_pEngine;
void InitDLL(cTestClass *l_pTestClass)
{
g_pEngine = l_pTestClass;
}
void UpdateDLL()
{
int i = 8;
float f = 0.08f;
g_pEngine->PrintText("Hello, World");
g_pEngine->PrintText("The number 8:");
g_pEngine->PrintInt(&i);
g_pEngine->PrintText("The number 0.08:");
g_pEngine->PrintFloat(&f);
}
void CloseDLL()
{
g_pEngine = 0;
}
EXPORTS
InitDLL
UpdateDLL
CloseDLL