From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10180 invoked by alias); 17 Oct 2013 05:48:40 -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 10161 invoked by uid 89); 17 Oct 2013 05:48:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-bk0-f43.google.com Received: from mail-bk0-f43.google.com (HELO mail-bk0-f43.google.com) (209.85.214.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 17 Oct 2013 05:48:38 +0000 Received: by mail-bk0-f43.google.com with SMTP id mz13so617018bkb.2 for ; Wed, 16 Oct 2013 22:48:35 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.205.10.200 with SMTP id pb8mr5565183bkb.16.1381988915267; Wed, 16 Oct 2013 22:48:35 -0700 (PDT) Received: by 10.205.68.134 with HTTP; Wed, 16 Oct 2013 22:48:35 -0700 (PDT) In-Reply-To: <80070575041F1A43B43673DA71C5B0BCBBE2B2EC65@INBLRK77M1MSX.in002.siemens.net> References: <80070575041F1A43B43673DA71C5B0BCBBE2B2EBBC@INBLRK77M1MSX.in002.siemens.net> <80070575041F1A43B43673DA71C5B0BCBBE2B2EC65@INBLRK77M1MSX.in002.siemens.net> Date: Thu, 17 Oct 2013 05:48:00 -0000 Message-ID: Subject: Re: how could make gcc link static library default? From: Terry Guo To: "Anandkumar, CB IN BLR STS" Cc: "net_robber@timectrl.net" , "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-10/txt/msg00052.txt.bz2 On Thu, Oct 17, 2013 at 1:05 PM, Anandkumar, CB IN BLR STS wrote: > Hi Terry, > Normally dynamic is given more preference over static so this sho= uld work. > Got your point. Thanks. BR, Terry > 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 w= ith example mentioned below: >> If you have want to compile a program test.c which is dependent = on 2 static library foo1 and foo2 and one dynamic library foo3 then below m= entioned 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 simi= lar scenario: sometimes the foo3 exists in dynamic library, sometimes it ex= ists in static library. Is it possible to let gcc search the dynamic one fi= rst and then search the static one if dynamic doesn't exist? Does command l= ike 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 choos= e the dynamic one over the static one or choose the static one over the dyn= amic 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 ign= ore 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?