Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

Builind interdependent dunamic libraries

Frequent Advisor

Builind interdependent dunamic libraries


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 using the following link line
CC -b +Z +DAportable -Wl,+vshlibunsats,-B,symbolic,+s -o *.o
(I get all the symbols defined in as unsatisfied).

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

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

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

and then moved

Now if I do a lld -r on and, 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?

Honored Contributor Honored Contributor

Re: Builind interdependent dunamic libraries


The above process is creating the libraries with same funtions. It is because, is created with all *.o files funtions. So lTest1 is ready to build with other applications. is created with same *.o funtions which linked in the library.

In 3rd step,you are trying to rebuild the library with the library which is linked using creations asks the linked functions of and calls the linked functions of So modification needs it's previous update from

To remove this,create the without the library. Now it will be created. creation as like And you are replacing to the So no problem will come for that.

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

Easy to suggest when don't know about the problem!
Esteemed Contributor 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)