View Single Post
How to detect dynamic library load/unload?
Old
  (#1)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default How to detect dynamic library load/unload? - 18-10-2004

I want to get my linux loadable library to run a function whenever it is loaded and unloaded.

I know how to to this in windows using the entry/exit function

BOOL WINAPI DllMain
( HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)

Under linux g++ I read that I should use these function macros

__init and __exit

I created two functions for my library based on examples I saw,

static void __init StartUp(void)
static void __exit ShutDown(void)

But these functions do not get called when dlopen is called or when the libary is unloaded.

Can anyone help me with this?


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote