Re: Should .a library contains non-reallocatable code?
Jeff Epler writes ("Re: Should .a library contains non-reallocatable code?"):
> On Thu, Feb 19, 2015 at 05:19:30PM -0600, Jeff Epler wrote:
> > * foomodule is a Python wrapper for libfoo, so it must be shipped
> > as a .so, but if it links libfoo.a, and libfoo.a is not -fPIC,
> > it is not possible to build foomodule at all
> >
> > (The same goes for wrapping the library for most other interpreted
> > languages)
>
> So here is a concrete example of this. I chose libtomcrypt at
> semi-random, because in libtomcrypt-dev 1.17-6 there is both a shared
> library and a static library; the latter has non-PIC code.
This is of course an artificial example. Because libtomcrypt has a
shared library, it would be better to use that and avoid all of these
problems.
But if libtomcrypt had only a .a (perhaps because it has no stable
ABI) then it ought to be compiled -fPIC, to avoid the problem you
describe.
In that case your tommodule.o ought to be compiled with -Bdynamic (or
use a version file, as you demonstrate).
Thanks,
Ian.
Reply to: