From owner-freebsd-questions@FreeBSD.ORG Fri May 1 21:22:55 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C0C2DF3A for ; Fri, 1 May 2015 21:22:55 +0000 (UTC) Received: from mail-ig0-x236.google.com (mail-ig0-x236.google.com [IPv6:2607:f8b0:4001:c05::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8BBDB1EAB for ; Fri, 1 May 2015 21:22:55 +0000 (UTC) Received: by igblo3 with SMTP id lo3so47847063igb.1 for ; Fri, 01 May 2015 14:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=FGu4k+5pDlpOkGr/mmRJcKDobGbqlFFQi0bfH6X/8wM=; b=TGAWd+FRmAzRthBjSuqinxp09tjIHvJqlFLNNpORHZblEcHbHhrlswnxUSUy9HbJBZ KE5S2yp3sBPeydQgVCZEgkE6bCEARUvC/Zgry+OpFqGrnR7A98KqyqtW2wGGB0Tk8eTN 8JeldSroT60yiWzqK25D87jRl3HvDCdByKA0KzaMnwnGVv5P82kRYKcWpHL9eBGWKrN3 OcE1OyPSK1NRECKEx+9U88wHlXC+GDW4x74RVyNlVBmH9fhpO4/K/es2nefHAjuZ0qhp FK8R9MYyc6GX/i9rKnBsspzvjWGrYgvtosKShmIUbhaGb6WxsJwQhog72qBKdrKUqQ/k PvAQ== X-Received: by 10.43.180.137 with SMTP id pe9mr3542607icc.90.1430515375076; Fri, 01 May 2015 14:22:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.131.194 with HTTP; Fri, 1 May 2015 14:22:34 -0700 (PDT) In-Reply-To: <5543E9D5.2030404@paz.bz> References: <5543E9D5.2030404@paz.bz> From: Alex Merritt Date: Fri, 1 May 2015 17:22:34 -0400 Message-ID: Subject: Re: compiling static To: Jim Pazarena Cc: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 May 2015 21:22:55 -0000 On Fri, May 1, 2015 at 5:02 PM, Jim Pazarena wrote: > is there a way to tell cc (clang) to compile with static libraries? If you want to _compile_ code to a static library, you generate the object files and then use "ar" to assemble them together into an archive file (.a). cc -c file0.c file1.c ... ar rcus lib.a file0.o file1.o ... If you want to _link to_ (if that's what you mean by "compile with") static libraries, you may specify the archive path to the linker instead of using the dynamic linker flag (-l). cc prog.c /path/to/lib.a -o prog There may be other ways I am unfamiliar with. Is this not how gcc does it also? -Alex