Compiling (static vs dynamic linking)...

For discussions about programming and projects not necessarily associated with Porteus.
fullmoonremix

Compiling (static vs dynamic linking)...

Post#1 by fullmoonremix » 25 May 2016, 09:34

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 73.150.85.78 via http://webwarper.net
This is added while posting a message to avoid misusing the service
Last edited by fullmoonremix on 29 May 2016, 10:16, edited 1 time in total.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

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

Post#2 by ncmprhnsbl » 25 May 2016, 21:20

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 blender.org 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
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

xenos
Black ninja
Black ninja
Posts: 40
Joined: 20 Aug 2016, 22:20
Distribution: Porteus
Location: Blackhole

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

Post#3 by xenos » 01 Nov 2016, 18:49

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

Post Reply