Really setting up a project file is the only barrier, after that it is smooth sailing and rather easy:
The short version --- glossing over platform differences and using Windows as an example:
DLL source:
Code: Select all
#include <stdio.h>
#include <stdarg.h>
#define DLLEXPORT __declspec(dllexport) // This is a Windows define, btw ...
DLLEXPORT int Number_Get (void)
{
static int counter = 0;
return ++counter;
}
Code: Select all
#define APIENTRY WINAPI // On a non-Windows platform, this APIENTRY would likely be defined as "nothing" to smooth over platform differences.
int (APIENTRY *Number_Get) (void); // Function prototype
int dllhookup (void)
{
int loaded_ok = 0;
HINSTANCE hDLL = LoadLibrary(TEXT("mydll_debug.dll")); // Load the DLL
if (hDLL)
{
if ( (Number_Get = GetProcAddress(hDLL, "Number_Get") ) ) // Wire up the function but looking up the procedure name
loaded_ok = 1;
else
loaded_ok = -1;
}
return loaded_ok;
}