Question 1: Is there a way to do this in linux?
No. UNIX systems in general (with notable exception of AIX), and Linux in particular, consider a.out
and libfoo.so
"fully cooked" and "final". There is no way to relink them.
I want to create a shared library libA.so which does not refer to any other (static or shared) library.
You can do that by linking objects that would have been linked into libB.so
into libA.so
instead.
Note however that if your users want to link against libB.so
on their own, then you need to be extra careful to not violate one definition rule. This can be achieved by hiding all libB
's symols inside libA.so
(instructions here).
Also note that doing this may have licensing implications -- if libB
is distributed under GPL, then linking it into libA
creates a derivative work that must also be distributed under the same license.