This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Use ar to merge libraries?


It's a quite lame time-honored approach. Is there any utility to
creating nested .a files? If not, it shouldn't be very hard to change
ar's default behavior to merge in .a's, rather than nest them. 

Andrew

> -----Original Message-----
> From: Michael Meissner [mailto:meissner@cygnus.com]
> Sent: Wednesday, June 06, 2001 2:41 PM
> To: Andrew Begel
> Cc: binutils@sources.redhat.com; abegel@cs.berkeley.edu
> Subject: Re: Use ar to merge libraries?
> 
> 
> On Wed, Jun 06, 2001 at 02:13:24PM -0700, Andrew Begel wrote:
> > Without using the MRI librarian compability commands, is 
> there a way for
> > ar to merge .a files when building a new library? 
> > i.e.
> > 
> > ar cru libbar.a bar1.o bar2.o
> > ar cru libfoo.a libbar.a foo.o 
> > 
> > The result here is libfoo.a, which, if I had my way, would 
> consist of
> > three .o's, bar1.o, bar2.o and foo.o. However, right now, this gives
> > *two* entries in libfoo.a, libbar.a and foo.o. Since libbar.a is now
> > nested inside libfoo.a, normal linking against libfoo.a of symbols
> > inside bar1.o and bar2.o won't work. 
> 
> Well there is always the time honored approach of extracting 
> all of the objects
> files, and recreating the archive:
> 
> 	mkdir foo
> 	cd foo
> 	for lib in ${LIBRARIES}; do
> 		ar x $lib
> 	done
> 	ar cr ../${TARGET} *
> 	ranlib ../${TARGET}
> 	cd ..
> 	rm -rf foo
> 
> -- 
> Michael Meissner, Red Hat, Inc.  (GCC group)
> PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
> Work:	  meissner@redhat.com		phone: +1 978-486-9304
> Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]