help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating Archives


From: Mike Shal
Subject: Re: Creating Archives
Date: Thu, 7 Apr 2011 09:35:14 -0400

On Thu, Apr 7, 2011 at 8:45 AM, Paul Smith <address@hidden> wrote:
> On Thu, 2011-04-07 at 13:42 +0530, Ajay Jain wrote:
>> I have a number of archives and I want to create another archive using
>> those individual archives. Is it possible? Will "ar -sr" do my job?
>
> This is really more of a question for the binutils team than GNU make,
> but no, standard ar does not allow the members to be added to an archive
> to be anything other than object files.  You cannot combine two archives
> with ar, directly, at least not with standard ar.  I suppose some
> versions of ar might have an advanced capability to do this but I've
> never seen it.
>
>
> You can write a script yourself to do it, by using ar to explode one of
> the archives to its constituent object files in a temporary directory,
> then adding them to the other.

GNU ar lets you do it if you use the MRI librarian script commands:

http://sourceware.org/binutils/docs/binutils/ar-scripts.html

IIRC you can do something like:
CREATE libhuge.a
ADDLIB libsmall1.a
ADDLIB libsmall2.a
ADDMOB extra.o
SAVE

You'd want to generate a script like that and pipe it to stdin for 'ar -M'.

Paul's suggestion is definitely more portable though, you just have to
deal with the mess of stuff in the temporary directory and make sure
things won't break if you try to generate two libhuge.a's at once.

I have no idea why it isn't a standard feature in ar - seems like it
would be useful.

-Mike



reply via email to

[Prev in Thread] Current Thread [Next in Thread]