Static item constructors not called in shared libs (mips-sgi-irix-6.5/gcc-3.0.4)

Dave Williss dwilliss@microimages.com
Fri Jun 7 09:50:00 GMT 2002


Ok, I found it.  Since this list is archived, I thought I'd post
the answer in case anybody else has this problem and searches
the archive for clues.

The answer is to stop calling ld directly.  Link the shared library
with gcc -shared instead.  Ignore all the stuff in the ld man page
(sgi's ld, not gnu ld) about the -cxx parameter which it says will
arrange for the magic needed by C++ programs.  This apparently
only applies if you're using SGI's C compiler instead of gcc.

I now have programs running with shared libraries which have
static class data, and it's getting properly constructed.  Woo Hoo!

Dave Williss

----- Original Message -----
From: "Dave Williss" <dwilliss@microimages.com>
To: <gcc-help@gcc.gnu.org>
Sent: Wednesday, June 05, 2002 5:55 PM
Subject: Fw: Static item constructors not called in shared libs
(mips-sgi-irix-6.5/gcc-3.0.4)


> I just posted this to gcc-bugs, but the more I look at it,
> the more I think it's not a bug, I'm just missing something.
> I just don't know what.
>
> ----- Original Message -----
> From: "Dave Williss" <dwilliss@microimages.com>
> To: <gcc-bugs@gcc.gnu.org>
> Sent: Wednesday, June 05, 2002 5:52 PM
> Subject: Static item constructors not called in shared libs
> (mips-sgi-irix-6.5/gcc-3.0.4)
>
>
> > Constructors for C++ static data in a shared library is not
> > being called.  This is on an mips-sgi-irix-6.5 with gcc 3.0.4
> >
> > I checked the man page for ld and found a -cxx parameter
> > that you have to pass to make the magic work but it still
> > doesn't.
> >
> > I noticed the SGI linker also has -init and -fini parameters
> > that let you specify functions to call when loading/unloading
> > the shared lib, but there doesn't seem to be anything I
> > can pass (__initialize or something).  Is there something
> > else I need to do to make my shared library C++ aware?
> >
> >  -- Dave Williss
> > ------
> > Meddle not in the affairs of dragons,
> >    for you are crunchy and taste good with catsup
> >
> >



More information about the Gcc-help mailing list