This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Apache module in C++

Alexandre Oliva wrote:

> On Jun 22, 2001, Jes Rahbek Klinke <> wrote:
> > My problem is, that contructors and destructors of global variables is
> > not called, as the main apache executable is not aware of C++.
> > Does anyone know if collect2 can do this, and how?
> Presumably, linking your C++ shared library using g++, which already
> uses collect2, should get initializers to run when your module is
> dlopen()ed, and global destructors to run when it's dlclose()d (but
> beware static variables in function scope; these are scheduled for
> destruction with atexit(), so they'll only run when the whole
> application terminates, which may be long after the module is
> dlclose()d)
> If a module created with g++ won't have initializers run at dlopen()
> time, odds are that the OS you're running doesn't support this
> feature.  Fortunately, such OSs are rare these days.

You are absolutely right, if I compile with the command
$ g++ -g -fPIC -c
and link with
$ g++ -shared -fPIC -o

all the global construtors will be called when the module is loaded by
The only problem was for me to realize, that there was no problem at all.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]