2

Suppose I have a shared library A.so on computer #1, and then I build another shared library B.so on #1 which is dependent on A.so. My question is: could I use B.so in another almost the same computer #2 which does not have A.so?

Should there be a mechanism that I can include A.so in B.so, so I don't need A.so any longer?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
kevin
  • 824
  • 1
  • 9
  • 14
  • It might be possible. However, there is an easier way to do things: just set the rpath, and distribute A.so with B.so. – Dietrich Epp Sep 07 '14 at 22:23
  • 1
    Not as far a I am aware. The other computer needs A.so. They are "Shared Objects" and not "Static libraries". If it was a A.a and B.a then B.a could statically link A.a and what you describe would work.. Maybe someone else might know a way.. I don't :l – Brandon Sep 07 '14 at 22:23
  • 1
    Find a source code of `A.so`! ;) – Ivan Aksamentov - Drop Sep 07 '14 at 22:30
  • @DietrichEpp I am not familiar with rpath. It seems that it helps the linker to locate A.so, but here, on computer#2, there is no A.so. – kevin Sep 08 '14 at 00:41
  • @Beta Thanks. The link you gave describes the same problem as mine; however they have the source code for both A and B. I only have the source file of B. – kevin Sep 08 '14 at 00:42
  • @Drop so it is impossible to manage it without source file of A. Right ? – kevin Sep 08 '14 at 00:47
  • In that case I know of no way to do it, but I can't say that it's impossible. Everything I've read says that shared libraries can't be manipulated that way, but they don't say *why.* – Beta Sep 08 '14 at 01:37
  • See also [Pack shared libraries into the ELF](http://stackoverflow.com/questions/386579/pack-shared-libraries-into-the-elf) where the answers discuss some tools that might help. – Jonathan Leffler Sep 08 '14 at 03:24
  • @kevin: you would then distribute A.so and B.so together. The rpath just allows you to do this without installing A.so in a privileged location, such as `/usr/lib`. – Dietrich Epp Sep 08 '14 at 03:51
  • @DietrichEpp Ok, then I choose to persuade the superuser to install both A and B on computer#. Thanks. – kevin Sep 08 '14 at 13:35
  • Thank you guys for all the helpful information. It is time to close this post now. – kevin Sep 08 '14 at 13:36

0 Answers0