What is the difference between object adn library ?

Hi,

I'd like to know the difference object file and library file.s

All that I know about the difference is that library is the hierarchical

Reply to
jyyun
Loading thread data ...

A library file probably does have a more complex structure. It is meant to hold a pool of code, some which will be linked into the program and some which will be left out. The library file will probably need information on which routines need to be copied over when one perhaps requires several other routines. One could possibly do that with a linker which links in the initial routine, then iterates until no more references are resolved but it would be more efficient to have some structure that all routines that are depended on are also brought in at the same time.

Reply to
Gary Kato

"jyyun" wrote in news:bstggu$a4o$ snipped-for-privacy@news.kreonet.re.kr:

A library is a collection of object files.

I don't see why a library has to be hierarchical. It's just a container for object files.

--
- Mark ->
--
Reply to
Mark A. Odell

Not really. Unix *.a style libraries survived for quite a while without any such table. It's trivial for the linker implementor to treat a library as just a big bag full of .o files, which is what they really are --- the linker has to know how to deal with lots of .o files, and a list of as yet unresolved references, anyway, so there's nothing new about lots of .o files packaged in a libfoo.a that it would have to treat specially.

Later, the Unix makers added an optional(!) tool called "ranlib" that set up a table of all externals provided by each .o file in the library for quick lookup inside the archive. Before that, it was customary to specifically order the .o files inside the archive such that providing modules came after ones needing what they provided, to the extent possible. That's what Unix has the "tsort" utility for.

Nowadays, 'ranlib' is typically integrated into 'ar'.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.