Linker question

Linker question

Post by Walter Wartenweile » Thu, 29 Apr 1999 04:00:00



Hi!

I'm not a real Unix speciaist thus I have a question about linking
libraries on Unix.

If only part of a library is needed in the executable, will all the
library be linked with it (static library), is their an option to change
that behavior, a special way to build the .a...


Thanks a lot

Walter Wartenweiler

 
 
 

Linker question

Post by Henning Makhol » Thu, 29 Apr 1999 04:00:00



> If only part of a library is needed in the executable, will all the
> library be linked with it (static library),

No. Basically a ".a" library is a collection of .o object files which
have been lumped together in a single file for convenience. The linker
only includes the minimum set of objects that is necessary to resolve
all of the external references your program contains.

Properly written libraries are written to consist of a lot of small
.o files so that programs will only contain those pieces that are
actually necessary for the particular program.

See ar(1).

--
Henning Makholm

 
 
 

Linker question

Post by G. Sumner Haye » Sat, 01 May 1999 04:00:00



> I'm not a real Unix speciaist thus I have a question about linking
> libraries on Unix.

> If only part of a library is needed in the executable, will all the
> library be linked with it (static library)

No, the static library (.a) is a collection of object files.  On most
systems, those object files containing symbols that you need will be
linked in in their entirety.

If you're using new versions of egcs and GNU ld on ELF systems, you can
use "-ffunction-sections" at build time to put the functions in a file
into different ELF sections, then you can link with "-gc-sections" to
garbage-collect those sections and include only the functions you want.
At least that's the rumor I've heard, but I haven't found a version of
ld that supports it yet.  And it's not supported with shared libraries,
though such support is planned (eventually, if someone contributes it).

--Sumner

 
 
 

1. Incremental Linker (Question)

Does anybody know of an incremental linker
ported or developed for Linux ?
thanx in advance
--------------------------------------------------

The MathWorks, Inc.     http://www.mathworks.com
24 Prime Park Way
Natick, MA 01760-1500

2. Newby site

3. dynamic linker question

4. Blocking ZONE TRANSFERS?

5. linker question

6. Pentium problems/performance

7. easy linker question, but i need help!

8. Tcsh in an xterm

9. Solaris 2.4 linker question

10. newbie linker question

11. GNU linker question

12. Linker question

13. Linker questions