Re: Number of Objects in Static Link Library



David T. Ashley wrote:
"Logan Shaw" <lshaw-usenet@xxxxxxxxxxxxx> wrote in message news:46893a21$0$30657$4c368faf@xxxxxxxxxxxxxxxxx
David T. Ashley wrote:
I've experimented with making Linux libraries (to shorten compile time) and statically linking against them. Works fine.

Up until this time, I've generated the libraries from object files that each represent a related group of functions and their data (for example, common string operations not performed by the standard library). The end result (I assume) is that if a symbol in the object file is referenced, the entire object file (all functions) is dragged in, even if just one function (out of maybe dozens) is referenced.
I'm not an expert on linkers, but as far as I know, the linker on a Unix
system will typically pull in only those symbols which are actually needed.
Are you sure it's working the way you've described?

I haven't tested it, but I'm 75% sure. With most linkers, the minimum amount that can normally be pulled in is one "module" or "translation unit". This normally corresponds to a single .o file that comes from either compiling a .c file or assembling an assembly-language file.

My question is about breaking up .c file further so that each function is compiled individually, then letting the linker sort it out.

GMP is compiled this way.

Just not sure what maximums exist. Is 10,000 symbols too many? I'm not sure.

I'm not aware of any explicit limit -- but then, there are
a lot of things I'm not aware of ...

This seems like a question you could answer with a simple
experiment: Write yourself a script that generates and compiles
ten thousand files with ten thousand function names, and see
whether you can put 'em all in a library and link against it.
Ten minutes to whip the script together, about three hours for
the compilations ... as I write, some eight and a half hours
have elapsed since you first posed the question: you could have
had your answer twice by now!

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Number of Objects in Static Link Library
    ... I've generated the libraries from object files that ... result is that if a symbol in the object file is referenced, ... I'm not an expert on linkers, but as far as I know, the linker on a Unix ... compiling a .c file or assembling an assembly-language file. ...
    (comp.unix.programmer)
  • Re: calling my custom function same as library function
    ... which is of concern with "global" linkers ... if the user's object file defining ... it then encounters an unsatisfied reference to mallocinside the ... standard libraries, then it will either satisify the reference from ...
    (comp.lang.c)
  • Re: Undefined references to library symbols
    ... I'm trying to link an object file to a library, ... message while compiling: ... As this is a linker invocation command, -O2, -Wall and -I arguments ... The object files and libraries must be specified in correct order on ...
    (comp.unix.programmer)
  • Re: Bands on an EEE PC
    ... I have tried the compiled linux install ... This is almost certainly an issue about libraries. ... the simplest in terms of library deps) and try compiling it. ...
    (rec.games.roguelike.angband)
  • Re: optional routine arguments
    ... A package may have 5 to 10 libraries. ... One is called as "complib libname member" ... routine which is called only by them and is not in a library. ... I use the good old I-N rule only when compiling source files supplied by other people, and when compiling 10-line test programs. ...
    (comp.lang.fortran)