[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Problem with _init and _fini functions



On Tue, Nov 14, 2000 at 02:29:34PM +0530, Saravanan Subbiah wrote:
> Hi,
> 
> I am trying to create a shared library in Linux. I want my
> shared library to do some initialization on loading and some
> cleanup on unloading.
> 
> I used _init and _fini functions to do the intializations. But
> since I am using C++, (g++) it is mangling the function names
> to _init__Fv and _fini__FV in the .o files
> 

I don't know if these functions are gcc specific - but I suspect
that they are.

It's much better to use a language mechanism - like a static
initializer in C++ to do your initialization.

According to the C++ standards, when you load the shared library,
the linker is responsible for calling your static initalizers 
(possibly via _init and _fini). 

Some versions of g++, which were broken had problems doing it, but
the recent ones should be ok.

	-Arun (Not a huge fan of writing gcc specific code)