From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24121 invoked by alias); 17 Oct 2013 05:06:34 -0000 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 Received: (qmail 24107 invoked by uid 89); 17 Oct 2013 05:06:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: krishna.sisl.co.in Received: from krishna.sisl.co.in (HELO krishna.sisl.co.in) (194.138.248.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Oct 2013 05:06:32 +0000 Received: from kaveri.sisl.co.in (kaveri.sisl.co.in [132.186.192.4]) by krishna.sisl.co.in (Postfix) with ESMTP id A138413E289; Thu, 17 Oct 2013 10:58:57 +0530 (IST) Received: from INBLRK77N3MSX.in002.siemens.net (inblrk77n3msx.in002.siemens.net [132.186.221.164]) by kaveri.sisl.co.in (Postfix) with ESMTP id CB91F3E61A7; Thu, 17 Oct 2013 10:18:03 +0530 (IST) Received: from INBLRK77M1MSX.in002.siemens.net ([132.186.221.151]) by INBLRK77N3MSX.in002.siemens.net ([132.186.221.164]) with mapi; Thu, 17 Oct 2013 10:35:40 +0530 From: "Anandkumar, CB IN BLR STS" To: "flameroc@gmail.com" CC: "net_robber@timectrl.net" , "gcc-help@gcc.gnu.org" Date: Thu, 17 Oct 2013 05:06:00 -0000 Subject: RE: how could make gcc link static library default? Message-ID: <80070575041F1A43B43673DA71C5B0BCBBE2B2EC65@INBLRK77M1MSX.in002.siemens.net> References: <80070575041F1A43B43673DA71C5B0BCBBE2B2EBBC@INBLRK77M1MSX.in002.siemens.net> In-Reply-To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00051.txt.bz2 Hi Terry, Normally dynamic is given more preference over static so this shoul= d work. With Regards, Anand -----Original Message----- From: Terry Guo [mailto:flameroc@gmail.com] Sent: Thursday, October 17, 2013 10:09 AM To: Anandkumar, CB IN BLR STS Cc: net_robber@timectrl.net; gcc-help@gcc.gnu.org Subject: Re: how could make gcc link static library default? On Thu, Oct 17, 2013 at 12:21 PM, Anandkumar, CB IN BLR STS wrote: > Hi, > You try both static and dynamic linking with following options wi= th example mentioned below: > If you have want to compile a program test.c which is dependent o= n 2 static library foo1 and foo2 and one dynamic library foo3 then below me= ntioned command will do the trick. > > gcc test.c -W1,-Bstatic -lfoo1 -lfoo2 -W1,-Bdynamic -lfoo3 -o > test > > > Try this trick on any number of static and dynamic libraries. Thanks for sharing and sorry for interrupting. I am thinking another simila= r scenario: sometimes the foo3 exists in dynamic library, sometimes it exis= ts in static library. Is it possible to let gcc search the dynamic one firs= t and then search the static one if dynamic doesn't exist? Does command lik= e below works? gcc test.c -Wl,-Bdynamic -lfoo3 -Wl,-Bstatic -lfoo3 -o test And if both dynamic one and static exist, is it possible to let gcc choose = the dynamic one over the static one or choose the static one over the dynam= ic one? Thanks. BR, Terry > > With Regards, > Anand > > -----Original Message----- > From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] > On Behalf Of net_robber > Sent: Thursday, October 17, 2013 9:10 AM > To: gcc-help@gcc.gnu.org > Subject: how could make gcc link static library default? > > hi, > > i know a option -static to force gcc link static library, which will igno= re shared library. > but in my case, some library just have shared library. > so, is want gcc linlk static library first, then shared library if > static one was not found > > how to do that?