Page 1 of 1

Compiling (static vs dynamic linking)...

Posted: 25 May 2016, 09:34
by fullmoonremix
Salutations... :good:

IMHO (please correct me if I'm wrong) :oops: from what I understand it seems that when linking...

... dynamically a dependency that requires a library (eg. musl/glibc) the result is... efficient (saves memory).
... statically anything else the result is... faster (improves performance).

"Best Regards"... :beer:

Posted by via
This is added while posting a message to avoid misusing the service

Re: Compiling (static vs dynamic linking)...

Posted: 25 May 2016, 21:20
by ncmprhnsbl
pretty much
just to expand a little:
Static linking is the result of the linker copying all library routines used in the program
into the executable image. This may require more disk space and memory than dynamic
linking, but is both faster and more portable, since it does not require the presence of
the library on the system where it is run.
examples: blender from or an .AppImage or something from portable apps or more loosely a porteus module containing needed libs/deps
Dynamic linking is accomplished by placing the name of a sharable library in the executable
image. Actual linking with the library routines does not occur until the image is run, when
both the executable and the library are placed in memory. An advantage of dynamic linking
is that multiple programs can share a single copy of the library.
examples: packages from distro repos

Re: Compiling (static vs dynamic linking)...

Posted: 01 Nov 2016, 18:49
by xenos
Application A depends on Library X, Y and Z

Assume there are some security fixes in Library X

Under static linking, user needs to recompile, rebuild, remake Application A to have updated fixes

Under dynamic linking,
user only needs to recompile, rebuild, remake Library X and any application that depends on Library X will have fixes updated