On 16/12/2012 17:22, Manish Jain wrote:
> Under /lib I have both versions - shared (libxyz.so.1) as well as static
> (libxyz.a) - of a library. How do I tell make to link to the static
> version, not the shared one ? The next obvious question is how to do the
> vice versa - tell make to link to the shared version, not the static one.

Add -static to the ld command line to produce a staticly linked binary:
this forbids ld(1) from doing any dynamic linking.  Otherwise ld will
default to dynamic linking, but fall back to linking staticly against
libraries where there isn't a dynamic shared object available.

Actually, there are about 4 different linker flags you could use that
mean 'produce a staticly linked binary.'  They don't have any different
effect; the reason they exist is for historic compatibility with
versions of ld(1) from many different sources.

It's also an all-or-nothing option.  If you wanted to use static linkage
for one particular library out of all the libraries used by your
program, then you'ld need a very different command line.  But that, as
they say, is left as an exercise for the student.

        Cheers,

        Matthew


-- 
Dr Matthew J Seaman MA, D.Phil.
PGP: http://www.infracaninophile.co.uk/pgpkey


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to