This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Static initializers and shared libraries
- To: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- Subject: Re: Static initializers and shared libraries
- From: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Date: 04 Nov 1999 14:48:37 -0200
- Cc: gcc-bugs at gcc dot gnu dot org, Jose dot Gomes at sophia dot inria dot fr, Frederic dot Devernay at sophia dot inria dot fr
- References: <199911041637.RAA30521@mururoa.inria.fr>
On Nov 4, 1999, Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> wrote:
> ld -G -o plugin.so plugin.o -L/usr/local/gcc/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2 -R/usr/local/gcc/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2 -lstdc++ -lgcc
> The compilation arguments have been set to mimic the behaviour of
> libtool, but every variation of those that we have tried also fail.
^^^^^^^
That's one of the possible causes of the problem. libtool doesn't
claim to support C++ because, on some platforms, dynamic
initialization of shared libraries won't occur. That's because, when
the linker used by gcc is Sun ld, not GNU ld, libtool decides that
it's not safe to run g++ -shared, and it calls ld directly. The
result is that the code gcc would introduce to take care of dynamic
initialization isn't introduced.
One solution for this problem, on Solaris, is to use g++ -shared to
create the shared library, just like on Linux, but then you have to
make sure that your libstdc++ is a shared library. If it is not
compiled with -fPIC, the linker will complain.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them