C++ constructors in shared libraries

C++ constructors in shared libraries

Post by Tim Wagn » Sun, 20 Aug 1995 04:00:00



I'm using g++ to create a shared library that I then explicitly
load into my process, using the "dlXXX" family of functions.
Everything works well except that global constructors & destructors
in the loaded code are not being invoked.  I can search for them
manually (it's not so hard to tell which they are), but I presume that
the compiler should be placing them in the right sections of the module
so that they are run automatically.

Does anyone have experience with this?  Is there a special step to
take that I'm missing, or perhaps a known Solaris bug related to
shared library loading through the dl API?  Thanks for any help!

Tim Wagner
U.C. Berkeley Ensemble Project

 
 
 

1. Static constructors not called for C++ shared library

Apologies if this has been covered before, but I have searched through
the newsgroup and the IBM web site and come up dry.

I am porting a shared library written in C++ to AIX, which is loaded
using load(). If I build a test application under AIX 4.1 to call the
library, the static constructors for my library do not get called. If I
build my application under AIX 4.2, it works fine.

I am concerned by the description for load() which states that "If the
program calling the load subroutine was linked on 4.2 or a later
release, the load subroutine will call initialization routines...". I do
not control the calling app, which is built pre-4.2.

I found one reference to this topic in May '95 AIXpert, it says to use
makeC++SharedLib which I am already doing.

Any pointers or advice welcome.

Glenn Langford

2. iptables question

3. Shared libs, C++, static constructor considerations

4. Sources for Linux Presentation

5. calling constructors - C++/Shared Object/Solaris/NSAPI

6. dhcp and mysql conflict

7. Multiply defined C++ constructors in Shared Objects

8. Knode: cannot get further than downloding list of news groups.

9. static constructor from shared library not getting called on aix when loaded by Apache Web Server

10. Will strip(debug shared library) == nodebug shared library ?

11. Help with building shared libraries with dependencies on other shared libraries

12. Question: Inclusion of shared libraries during linking of shared libraries

13. Shared library loading shared library.