• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Question/Observations about static lib linking and ranlib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question/Observations about static lib linking and ranlib


  • Subject: Question/Observations about static lib linking and ranlib
  • From: Rush Manbert <email@hidden>
  • Date: Fri, 31 Mar 2006 16:03:46 -0800

Hi all,

I have seen the threads where people complain that they need to run ranlib on their static libraries after they check them out from source code control, etc. I was always confused by this because, although I understand why ranlib needs to be run on the libraries, I wasn't running into ant linker problems.

I am using libxml, libxslt, Boost filesystem, and Boost regex, among other third party libraries. I built all of them on my local machine, then in many cases I re-install the libraries, which involves moving them and renaming them. When I do that I need to run ranlib on them, but I then check them into and out of CVS and I have never see any linker problems. The whole idea is to have a set of static libraries that are pre-built and used by all of our developers just by checking them out of the repository. I will refer to these below as the "repository libraries".

Today I tried to build an app that links against one of my repository libraries. The link failed, telling me that the library table of contents was out of date and that I had to run ranlib on it. I believe that the other times I have built this app I was linking against a freshly built library, not one that had been checked in/out. (This is a "repository tool" that follows the same pattern, so I built all of the tools and libraries at once and imported all of them to the repository. No one normally builds this tool, they just check it out.)

I have another app that I build all the time, and it uses my repository static libraries, plus some libraries that are always built from sources. I never need to run ranlib on any of the repository libraries. And I have wondered why. And I think I may have an answer.

The difference between these two apps is that the one that never gets linker errors is linked indirectly against all of the repository libraries. By this I mean that it links against one of my libraries that is always built from scratch, but that library is linked against libxml2, Boost, etc. My suspicion is that this has shielded me from the linker errors that I would expect to see. (And I do know that the repository library code gets linked in. The app wouldn't work otherwise.)

I build the single library all the time as well, and the linker never complains about the out-of-date static libs.

I think this means that when a static library target is linked, and it links against static libraries whose tables of contents are out of date, the "out of dateness" of those libraries is ignored by the linker. Can anyone confirm or deny this? It's the only explanation that fits all of the data I have.

I'm sharing this because it may provide a way for people to sidestep the link problems they are having, without resorting to just glomming everything together in a single object file. I happened to end up with this configuration because my app is pretty pure Obj-C, but all the libraries are C and C++, so the app just interfaces through an adapter layer in the one library and never references any of the repository libraries directly. I've felt sort of bad (not to mention a little nervous) because I wasn't seeing the expected "run ranlib" errors that others were experiencing. Maybe this will help a little. (Or maybe it's just a wild goose chase. :-)

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


  • Prev by Date: Re: extern "C" and global variables
  • Next by Date: Re: Xcode lets me link universal binary against thin static library
  • Previous by thread: Re: Xcode lets me link universal binary against thin static library
  • Next by thread: Xcode lets me link a Universal static library against thin static libraries
  • Index(es):
    • Date
    • Thread