In Windows, you can load DLLs implicitly when an executable's process loads. The DLL will unload when executable's process unloads. This is what we do with FMOD and SDL DLLs, for example.
I would like to instead explicitly load and unload a certain DLL, so that it is only taking up memory in the process when it is in use. I would accomplish this with calls to LoadLibrary() and FreeLibrary() Win32 APIs. While the library is loaded, I call GetProcAddress() to retrieve pointers to DLL-exported functions.
I assume there's ways to do the same thing in Irix, OSX, Linux, etc. I'd appreciate advice on handling portability issues, particularly from Schik and Ross.
Offhand, I think I'd just create a simple wrapper class in BackEndLib:
class CTempDLL
{
public:
CTempDLL(const WCHAR *pwzDLLName);
bool Load(void);
void Unload(void);
PROC GetProc(const char *pszProcName);
};
-Erik
____________________________
The Godkiller - Chapter 1 available now on Steam. It's a DROD-like puzzle adventure game.
dev journals |
twitch stream |
youtube archive (NSFW)