Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Dec 2012 00:55:20 +0530
From:      Manish Jain <bourne.identity@hotmail.com>
To:        Matthew Seaman <matthew@FreeBSD.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Question on how do I tell make to choose between static and shared versions of a library
Message-ID:  <BLU0-SMTP622D4076445A28878A4297F6330@phx.gbl>
In-Reply-To: <50CE0816.30509@FreeBSD.org>
References:  <mailman.67.1355659202.33098.freebsd-questions@freebsd.org> <BLU0-SMTP1154DEA566E8A9677055BD5F6330@phx.gbl> <50CE0816.30509@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 16-Dec-12 23:12, Matthew Seaman wrote:
> 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
>
>


Thanks Matthew. That saved me a lot of time, and the man page for ld (as 
suggested by Polytropon) is not as informative on this particular 
subject as your response.


-- 
Regards,

Manish Jain
bourne.identity@hotmail.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BLU0-SMTP622D4076445A28878A4297F6330>