From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5976 invoked by alias); 29 Nov 2011 19:20:54 -0000 Received: (qmail 5963 invoked by uid 22791); 29 Nov 2011 19:20:52 -0000 X-SWARE-Spam-Status: No, hits=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Nov 2011 19:20:38 +0000 Received: by iahk25 with SMTP id k25so12127155iah.20 for ; Tue, 29 Nov 2011 11:20:38 -0800 (PST) Received: by 10.43.45.137 with SMTP id uk9mr19819icb.52.1322594438378; Tue, 29 Nov 2011 11:20:38 -0800 (PST) Received: by 10.43.45.137 with SMTP id uk9mr19802icb.52.1322594438237; Tue, 29 Nov 2011 11:20:38 -0800 (PST) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id bu33sm62764596ibb.11.2011.11.29.11.20.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 29 Nov 2011 11:20:37 -0800 (PST) From: Ian Lance Taylor To: "Weaver\, John P CIV" Cc: Subject: Re: prefer static linking References: <869832256C376241BB63955DA5CA5AA702B53725@nawechlkez01v.nadsuswe.nads.navy.mil> Date: Tue, 29 Nov 2011 23:56:00 -0000 In-Reply-To: <869832256C376241BB63955DA5CA5AA702B53725@nawechlkez01v.nadsuswe.nads.navy.mil> (John P. Weaver's message of "Tue, 29 Nov 2011 11:02:24 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes 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/msg00299.txt.bz2 "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