Liste des Groupes | Revenir à cl c |
On 2024-06-08, bart <bc@freeuk.com> wrote:The actual process of linking is a fairly trivial matter, as I showed in my 0.8Kloc C program which not only loads and relocates an executable file (in my format), but loads, relocates and does symbol fixups of any dynamic libraries. (Plus fixes up DLL dependencies too! But the relocation of those is done within OS routines at my request.)On 08/06/2024 01:39, Kaz Kylheku wrote:That's linking.On 2024-06-07, bart <bc@freeuk.com> wrote:>It's you who can't get your head around the idea that someone could be>
away with a 'linker'.
You can do away with linkers and linking.
>
But it's pretty helpful when
>
1. the same library is reused for many programs.
You use a shared library.
Static linking is the same thing as dynamic except it's being
precomputed: the libs are dynamically processed, but then rather
than the program being run, its image is dumped into an executable.
That executable no then longer needs to repeat that library processing
when started; everything is integrated. (There are ways to optimize
linking so not all the material must be present in memory all at once
as I describe it above.)
If you obtain a static library in the form of an object file or archive, then yes you will need a program that can process that file and combine it with the rest of your application: a linker.No, not always. There is such thing as selling static libraries.2. you're selling a library, and would like to ship a binary image of>
that library.
You ship a shared library.
Numerical code, crypto, codecs.
A few times in my career I worked with purchased static libs.
There are some advantages to it, like that static calls can beIf you do your own fixups (you generate an executable where DLL dependences are resolved via your initialisation code rather than getting the OS to do it), you can arrange it so that calls to imported routines are direct.
faster than dynamic,
removed at link time.Windows tends to use PE (which includes COFF). Linux tends to use ELF.
Another aspect is that it's possible for static libs to be
platform-independent, to an extent, because some of the
object formats like COFF are widely recognized. Whereas
shared libs tend to be very OS specific. The vendor has to make
them separately for Windows, Linux, Solaris, BSD, Mac, ...
This gruntwork is a pain in the ass that is removed fromSure. My tools can generate OBJ files if necessary. But then it'll be somebody else who needs to invoke a linker. Not me.
the core value of your code.
The integrator who buys your static lib can turn it into a
shared lib for their target system, if they are so inclined.
Les messages affichés proviennent d'usenet.