This is the mail archive of the gcc-bugs@gcc.gnu.org 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: Static initializers and shared libraries


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


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