Compiling (static vs dynamic linking)...

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

Compiling (static vs dynamic linking)...

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

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

Postby ncmprhnsbl » 25 May 2016, 22: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 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 :
User avatar
Full of knowledge
Full of knowledge
Posts: 726
Joined: 20 Mar 2012, 04:42
Location: australia
Distribution: 3.2.2-64bit xfce/openbox

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

Postby xenos » 01 Nov 2016, 19: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
White ninja
White ninja
Posts: 24
Joined: 20 Aug 2016, 23:20
Location: Blackhole
Distribution: Porteus

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest