Operating System - HP-UX
1748217 Members
4161 Online
108759 Solutions
New Discussion юеВ

Re: Builind interdependent dunamic libraries

 
Satya_6
Frequent Advisor

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
2 REPLIES 2
Muthukumar_5
Honored Contributor

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!
ranganath ramachandra
Esteemed Contributor

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)
 
--
ranga
[i work for hpe]

Accept or Kudo