Domanda

assume I extend a C++ function to python by creating libA.so, but libA.so depends also on another shared library libB.so. I want to distribute libA.so to a final user in a way that it already contains (embeds) libB.so, i.e. the final user does not need to obtain libB.so or to set his/her LD_LIBRARY_PATH to point to the folder containing libB.so (in the case this library is present in the final user's file system).

So basically I want to create a shared library libA.so which does not refer to any other (static or shared) library.

Question 1: Is there a way to do this in linux?

Question 2: Can this be done by configuring a python setup script based on distutils.core? (probably question 1 will also provide the answer to this)

Thanks

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top