Re: Builind interdependent dunamic libraries (322 Views)
Reply
Frequent Advisor
Satya_6
Posts: 74
Registered: ‎03-18-2003
Message 1 of 3 (322 Views)

Builind interdependent dunamic libraries

Hi,

I am facing a problem in building two dynamic libraries which depended on each other. I am able to build these 2 libraries on other platforms.

I am doing the following steps.

I build libTest1.sl using the following link line
CC -b +Z +DAportable -Wl,+vshlibunsats,-B,symbolic,+s -o libTest1.sl *.o
(I get all the symbols defined in lib2.sl as unsatisfied).

I build libTest2.sl using
CC -b +Z +DAportable -Wl,+vshlibunsats,-B,symbolic,+s -o libTest2.sl *.o -lTest1

Now if I try again to build the libTest1.sl using
CC -b +Z +DAportable -Wl,+vshlibunsats,-B,symbolic,+s -o libTest1.sl *.o -lTest2, I get an error as follows
/usr/ccs/bin/ld: Cannot specify input file (libTest1.sl) that is the same as the output file.

So I did
CC -b +Z +DAportable -Wl,+vshlibunsats,-B,symbolic,+s -o libTest3.sl *.o -lTest2

and then moved libTest3.sl libTest1.sl.

Now if I do a lld -r on libTest1.sl and libTest2.sl, I find both libTest1 and libTest2 in both the libraries.

I am using aCC: HP ANSI C++ B3910B A.03.30 compiler.

Is it ok to design the libraries like this (which depend on each other)?
What is the correct way to build such libraries?

TIA
satya
Honored Contributor
Muthukumar_5
Posts: 4,030
Registered: ‎06-09-2004
Message 2 of 3 (322 Views)

Re: Builind interdependent dunamic libraries

Hai,

The above process is creating the libraries with same funtions. It is because,

libTest1.sl is created with all *.o files funtions. So lTest1 is ready to build with other applications.

libTest2.sl is created with same *.o funtions which linked in the libTest1.sl library.

In 3rd step,you are trying to rebuild the libTest1.so library with the libTest2.sl library which is linked using libTest1.sl.

libTest1.sl creations asks the linked functions of libTest2.sl and libTest2.sl calls the linked functions of libTest1.sl. So libTest1.sl modification needs it's previous update from libTest1.sl

To remove this,create the libTest2.sl without the libTest1.sl library. Now it will be created.

libTest3.sl creation as like libTest2.sl. And you are replacing libTest3.sl to the libTest1.sl. So no problem will come for that.

So two libraries contains the same libraries. check ldd or ldd -r command.

Regards,
Muthukumar.
Easy to suggest when don't know about the problem!
Esteemed Contributor
ranganath ramachandra
Posts: 375
Registered: ‎05-16-2003
Message 3 of 3 (322 Views)

Re: Builind interdependent dunamic libraries

1. is it ok to have interdependent shared libraries (will they have runtime problems)?

it is fine to have such dependencies. we build /usr/lib/libdld.2 with a dependency on libc.2 which in turn needs libdld.2.

2. what is the right way to build them?

i guess the linker error is a mistake. this problem does not happen with the pa64 linker. we will fix ld32 for this. till then, the way you are building them is ok.

by the way, are you using CC or aCC? CC is obsolete and its usage is discouraged.
--
ranga (pa-risc linker/loader team)
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.