Hello!
There is a problem with libtool 1.5.6 while building
shared libraries.
If we configure and find standard ld (/usr/ccs/bin/ld),
then libtool uses it while building shared library. But the initialization and
finalization routines are not being mentioned (these are options –z initarray
and –z finiarray). However, if we set LD=/opt/SUNWspro/bin/cc, then it
works ok.
For example, if we have small program to compile with
“cc: Sun C 5.5 2003/03/12” from Sun ONE Studio 8:
aaa.c:
void mod_init()
{
printf(init\n”);
}
void mod_fini()
{
printf(“fini\n”);
}
#pragma init(mod_init)
#pragma fini(mod_fini)
and make a shared library:
- cc –KPIC –DPIC –G –o libaaa.so
aaa.c
or
- cc –KPIC –DPIC –c aaa.c; ld –G
–o libaaa.so aaa.o
in first case we have routines called, in second one –
this is what libtool –-mode=link does - we haven’t.
I use the workaround – setting LD to cc, but
the other solution may be the unified way of specifying initialization and
finalization routines with some options to libtool –mode=link. We have
pragmas in Sun cc, another way in gcc, and whatever in other compilers.