Announcement: Be excellent to each other.


Caravel Forum : Caravel Boards : Development : How portable is LoadLibrary()?
New Topic New Poll Post Reply
Poster Message
ErikH2000
Level: Legendary Smitemaster
Avatar
Rank Points: 2794
Registered: 02-04-2003
IP: Logged
icon How portable is LoadLibrary()? (0)  
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)
05-28-2003 at 06:54 PM
View Profile Send Email to User Show all user's posts This architect's holds Quote Reply
ross
Level: Delver
Rank Points: 30
Registered: 05-17-2003
IP: Logged
icon Re: How portable is LoadLibrary()? (0)  
ErikH2000 wrote:
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.

yes, we can't use LoadLibrary() though we do have the dlopen() and dlsym() calls so it's not a problem. To quote someone I was working with today "Fill ya boots" (no I don't know what it means - I assume it means go for it or something).

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
if you did that (with a base class) and then implemented CWindowsTempDLL then I could probably knock up a CUnixTempDLL in a couple of minutes ( Schik could probably do it even quicker ).

if you have a preference not to do it this way then just rest assured it's possible. The base class, platform specific derived (with a factory class) is just my personal preference in general.

05-28-2003 at 08:37 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Schik
Level: Legendary Smitemaster
Avatar
Rank Points: 5383
Registered: 02-04-2003
IP: Logged
icon Re: Re: How portable is LoadLibrary()? (0)  
ross wrote:
I could probably knock up a CUnixTempDLL in a couple of minutes (Schik could probably do it even quicker)
Or maybe - just maybe... Schik was waiting for someone else to answer this because he didn't know how to do it. :eyes

Schik also likes to talk about himself in the third person.

____________________________
The greatness of a nation and its moral progress can be judged by the way it treats its animals.
--Mahatma Gandhi
05-28-2003 at 08:40 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5058
Registered: 02-04-2003
IP: Logged
icon Re: Re: Re: How portable is LoadLibrary()? (0)  
Schik wrote:
Schik also likes to talk about himself in the third person.
Hmm...I don't see the problem here. I don't mind talking about Schik in the third person. Oh, wait... ;)
05-28-2003 at 09:00 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
ErikH2000
Level: Legendary Smitemaster
Avatar
Rank Points: 2794
Registered: 02-04-2003
IP: Logged
icon Re: Re: How portable is LoadLibrary()? (0)  
ross wrote:
yes, we can't use LoadLibrary() though we do have the dlopen() and dlsym() calls so it's not a problem. To quote someone I was working with today "Fill ya boots" (no I don't know what it means - I assume it means go for it or something).
This is good information, though it turns out I don't need to use explicit loading to solve the problem I was working on. It will come up again though.

-Erik

____________________________
The Godkiller - Chapter 1 available now on Steam. It's a DROD-like puzzle adventure game.
dev journals | twitch stream | youtube archive (NSFW)
05-28-2003 at 09:08 PM
View Profile Send Email to User Show all user's posts This architect's holds Quote Reply
ross
Level: Delver
Rank Points: 30
Registered: 05-17-2003
IP: Logged
icon Re: How portable is LoadLibrary()? (0)  
Oh I thought for a moment you were going to dynamically load the Monster*.cpp classes (like Serpent etc). Ah well.

I'll wait for the 2.0 rewrite in C# ;) (just a joke, seems like everyone is doing it ATM).

Does anyone here ever use IRC?

[Edited by ross on 05-28-2003 at 08:16 PM]
05-28-2003 at 09:15 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
ErikH2000
Level: Legendary Smitemaster
Avatar
Rank Points: 2794
Registered: 02-04-2003
IP: Logged
icon Re: Re: How portable is LoadLibrary()? (0)  
ross wrote:
Oh I thought for a moment you were going to dynamically load the Monster*.cpp classes (like Serpent etc). Ah well.
Stuff like that is planned for later.

-Erik


____________________________
The Godkiller - Chapter 1 available now on Steam. It's a DROD-like puzzle adventure game.
dev journals | twitch stream | youtube archive (NSFW)
05-28-2003 at 09:18 PM
View Profile Send Email to User Show all user's posts This architect's holds Quote Reply
shurcooL
Level: Delver
Rank Points: 40
Registered: 04-26-2003
IP: Logged
icon Re: How portable is LoadLibrary()? (0)  
umm...

dlls on linux? i don't think so.

____________________________
Thanks,
shurcooL
05-28-2003 at 10:54 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
Schik
Level: Legendary Smitemaster
Avatar
Rank Points: 5383
Registered: 02-04-2003
IP: Logged
icon Re: Re: How portable is LoadLibrary()? (0)  
shurcooL wrote:
umm...

dlls on linux? i don't think so.
You're right. They're .so files on Linux and other Unixes.


____________________________
The greatness of a nation and its moral progress can be judged by the way it treats its animals.
--Mahatma Gandhi
05-28-2003 at 10:55 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
ross
Level: Delver
Rank Points: 30
Registered: 05-17-2003
IP: Logged
icon Re: How portable is LoadLibrary()? (0)  
Except on MacOS where they are .dylibs or .so or .lib or .jnilib .... ad nausea...

Same principle shurcool ... it's just that DLL trips off the tongue ...

[Edited by ross on 05-28-2003 at 09:59 PM]
05-28-2003 at 10:58 PM
View Profile Send Private Message to User Show all user's posts Quote Reply
ErikH2000
Level: Legendary Smitemaster
Avatar
Rank Points: 2794
Registered: 02-04-2003
IP: Logged
icon Re: Re: How portable is LoadLibrary()? (0)  
shurcooL wrote:
dlls on linux? i don't think so.
I just meant a library which is loaded dynamically, whatever its file extension is.

-Erik

____________________________
The Godkiller - Chapter 1 available now on Steam. It's a DROD-like puzzle adventure game.
dev journals | twitch stream | youtube archive (NSFW)
05-28-2003 at 11:27 PM
View Profile Send Email to User Show all user's posts This architect's holds Quote Reply
shurcooL
Level: Delver
Rank Points: 40
Registered: 04-26-2003
IP: Logged
icon Re: Re: Re: How portable is LoadLibrary()? (0)  
ErikH2000 wrote:
I just meant a library which is loaded dynamically, whatever its file extension is.

that's what i thought... ÷)

____________________________
Thanks,
shurcooL
05-29-2003 at 01:34 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Caravel Boards : Development : How portable is LoadLibrary()?
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.