Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Architecture info from archive members
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Architecture info from archive members



You should only run ranlib on the .a file, and not on the intermediate .o files.

From the "ar" man page:

-S Do not generate an archive symbol table. This can speed up
building a large library in several steps. The resulting archive
can not be used with the linker. In order to build a symbol ta-
ble, you must omit the S modifier on the last execution of ar, or
you must run ranlib on the archive.


You can also strip out the ``__.SYMDEF'' section, but it's actually going to be easier on you if you do not put it in in the first place.

I guess this begs the question of why are you using static libraries instead of dynamic libraries and libtool in the first place?

-- Terry

On Jul 22, 2008, at 11:15 PM, Rohitash Panda wrote:
Hi,
I think this excert from the Unix Porting guide probably explains why I am hitting the issue :
" The library archive utility, ar, cannot work with libraries containing code for more than one
architecture (or single-architecture libraries generated with lipo) after ranlib has added a table
of contents to them. Thus, if you need to add additional object files to a library, you must keep a
separate copy without a TOC. "


I have a archive wrapper that basically does some sanity checking before calling "ar cr .." and does a
"ranlib -s" after that.This is done for each .o file that needs to be archived , as and when the .o files are
compiled on the fly , incrementally creating the whole library.


I have a question related to the "ranlib -s" command that I run for each .o file . Is "ranlib -s" supposed to be run
at the end , after all the .o's have been archived ( ar cr .. ) , or is it fine to run it for each .o that gets archived ?
If so , are there any side effects incase we run it each time ? Because , I do see a lot of warnings like as below
for each .o file that gets archived through my wrapper script :


ranlib: file: libarchive.a(qme.o) has no symbols

Tx,
~

Terry Lambert wrote:
On Jul 22, 2008, at 7:52 AM, Rohitash Panda wrote:
Hi,
I face an issue quite often , which seems to be accidentally mixing 32-bit & 64-bit code in an archive.
When I try to see the contents of such an archive running "ar tv <Libarchive>" , it doesn't allow me
to see the contents :


$ ar tv libarchive.a
ar: libarchive.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: libarchive.a: Inappropriate file type or format


Is there any tool which can give a listing ( Eg objdump -a <libarchive> on Linux ) along with its architecture information
, so as to catch the culprit ?


A Universal binary has multiple mach-o files. Generally, you lipo out the mach-o you want to look at with "ar" and look at it with "ar".

   file <library name>
   otool -f <library name>

You may also want to take ar's advice and look at libtool, specifically the -arch_only flag.

-- Terry

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Unix-porting mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Architecture info from archive members (From: Rohitash Panda <email@hidden>)
 >Re: Architecture info from archive members (From: Terry Lambert <email@hidden>)
 >Re: Architecture info from archive members (From: Rohitash Panda <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.