From owner-freebsd-questions@FreeBSD.ORG Sun Dec 16 19:26:16 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1980CC54; Sun, 16 Dec 2012 19:26:16 +0000 (UTC) (envelope-from bourne.identity@hotmail.com) Received: from blu0-omc1-s22.blu0.hotmail.com (blu0-omc1-s22.blu0.hotmail.com [65.55.116.33]) by mx1.freebsd.org (Postfix) with ESMTP id BFC258FC0C; Sun, 16 Dec 2012 19:26:15 +0000 (UTC) Received: from BLU0-SMTP62 ([65.55.116.8]) by blu0-omc1-s22.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 16 Dec 2012 11:25:08 -0800 X-EIP: [QerFjvy2WPm3ABKu/5FdwEwwsR37ClHmFfYm3FCCDls=] X-Originating-Email: [bourne.identity@hotmail.com] Message-ID: Received: from [127.0.0.1] ([121.245.133.177]) by BLU0-SMTP62.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 16 Dec 2012 11:25:06 -0800 Date: Mon, 17 Dec 2012 00:55:20 +0530 From: Manish Jain User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 To: Matthew Seaman Subject: Re: Question on how do I tell make to choose between static and shared versions of a library References: <50CE0816.30509@FreeBSD.org> In-Reply-To: <50CE0816.30509@FreeBSD.org> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Dec 2012 19:25:07.0069 (UTC) FILETIME=[0E6C32D0:01CDDBC3] Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Dec 2012 19:26:16 -0000 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