From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20464 invoked by alias); 29 Nov 2011 20:21:29 -0000 Received: (qmail 20453 invoked by uid 22791); 29 Nov 2011 20:21:19 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NAWESDNIAX03O.nmci.navy.mil (HELO NAWESDNIAX03O.nmci.navy.mil) (138.163.1.76) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Nov 2011 20:20:41 +0000 Received: from nawesdnieg05v.nadsuswe.nads.navy.mil (Gate1-Sandiego.nmci.navy.mil [138.163.0.41]) by (Symantec Mail Security) with SMTP id 18.33.04106.B2045DE4; Tue, 29 Nov 2011 20:27:23 +0000 (GMT) Received: from nawesdnieb14v.nadsuswe.nads.navy.mil ([10.0.10.80]) by nawesdnieg05v.nadsuswe.nads.navy.mil with Microsoft SMTPSVC(6.0.3790.4675); Tue, 29 Nov 2011 12:20:38 -0800 Received: from nawechlkeb04v.nadsuswe.nads.navy.mil ([10.4.119.20]) by nawesdnieb14v.nadsuswe.nads.navy.mil with Microsoft SMTPSVC(6.0.3790.4675); Tue, 29 Nov 2011 12:20:39 -0800 Received: from nawechlkez01v.nadsuswe.nads.navy.mil ([10.4.119.15]) by nawechlkeb04v.nadsuswe.nads.navy.mil with Microsoft SMTPSVC(6.0.3790.4675); Tue, 29 Nov 2011 12:20:37 -0800 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: prefer static linking Date: Wed, 30 Nov 2011 01:29:00 -0000 Message-ID: <869832256C376241BB63955DA5CA5AA702B53786@nawechlkez01v.nadsuswe.nads.navy.mil> In-Reply-To: References: <869832256C376241BB63955DA5CA5AA702B53725@nawechlkez01v.nadsuswe.nads.navy.mil> From: "Weaver, John P CIV" To: "Ian Lance Taylor" , "Jonathan Wakely" Cc: Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg00300.txt.bz2 Following the chain and playing around with the makefile has yielded the following, judicious use of both -Bdynamic and -Bstatic in front of the different -l statements does in fact change the behavior of the linker so that the desired outcome is achieved. Thank you both for your input. Patrick Weaver China Lake, CA Voice: (760) 939-8744 Email: john.p.weaver(at)navy.mil -----Original Message----- From: Jonathan Wakely [mailto:jwakely.gcc@gmail.com]=20 Sent: Tuesday, November 29, 2011 11:29 To: Weaver, John P CIV Cc: gcc-help@gcc.gnu.org Subject: Re: prefer static linking On Nov 29, 2011 7:03 PM, "Weaver, John P CIV" wrote: > > The gcc compiler prefers to use dynamic libraries in the linking phase. GCC just calls the linker, any preference is the linker's. For the GNU linker -Bdynamic and -Bstatic allow you to control whether dynamic or static libraries are used for each lib named with -l=20 See 'man ld' -----Original Message----- From: Ian Lance Taylor [mailto:iant@google.com]=20 Sent: Tuesday, November 29, 2011 11:21 To: Weaver, John P CIV Cc: gcc-help@gcc.gnu.org Subject: Re: prefer static linking "Weaver, John P CIV" writes: > The gcc compiler prefers to use dynamic libraries in the linking > phase. When porting software from one machine to another it is > frequently desirable to link to static libraries as much as possible > to account for different versions of the libraries. The -static flag > is useful when you do not need any dynamic library support but causes > the linker to fail if there is only a dynamic library for a particular > call. Is there a way to ask the linker to use static libraries when > possible and report the dynamic libraries that are needed to complete > the linking process? I am not aware of any such option. If you are using the GNU linker, you can tell it to prefer dynamic libraries using -Bdynamic and tell it to use only static libraries using -Bstatic, but I don't know of any option to tell it to prefer static libraries but use dynamic libraries if they are available. Ian