Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Static library v.s. dynamic library

29 views
Skip to first unread message

Tristan B. Kildaire

unread,
Mar 23, 2017, 12:23:28 PM3/23/17
to
General question.

A static library is one in which the library's code is put into the
program's source file and then compiled into a "monolith" executable.

A dynamic library is one that is not included in the program's source
code (as in the library's code is not included) but it is loaded during
some time in the program's execution.

Rick C. Hodgin

unread,
Mar 23, 2017, 12:35:14 PM3/23/17
to
Was that a question?

Your statement is correct. Static libraries have benefits in that
the code will always work the way it went out. Dynamic libraries
have benefits in that they can receive security and bug fixes without
affecting the original program, or requiring updates or re-installation
of the original program, but could potentially break when new updates
are sent out which alter the expected behavior, introducing bugs which
are essentially external to your core app.

Static libraries can also receive some special optimizations dynamic
libraries cannot, because the linker can perform fixups which allow
for the optimizations.

Thank you,
Rick C. Hodgin

Rick C. Hodgin

unread,
Mar 23, 2017, 12:39:46 PM3/23/17
to
On Thursday, March 23, 2017 at 12:23:28 PM UTC-4, Tristan B. Kildaire wrote:
Bear in mind also that the "source file" you're referring to here is not
source code. Static libraries typically come from .lib files, which are
symbolic binary files. They contain information for the linker, and not
information for the source code compiler.

Barry Schwarz

unread,
Mar 23, 2017, 12:41:55 PM3/23/17
to
On Thu, 23 Mar 2017 18:23:02 +0200, "Tristan B. Kildaire"
<dea...@disroot.org> wrote:

>General question.
>
>A static library is one in which the library's code is put into the
>program's source file and then compiled into a "monolith" executable.

A static library does not have source code. It has object modules.
They are linked with the programs object modules into a monolithic
executable which is not affected by any subsequent changes to the
library.

>A dynamic library is one that is not included in the program's source
>code (as in the library's code is not included) but it is loaded during
>some time in the program's execution.

The object modules of a dynamic library remain separate from the
programs executable and are loaded only during execution as required.
If a dynamic library changes between executions, the later executions
receive the updated versions of the modules.

--
Remove del for email

Scott Lurndal

unread,
Mar 23, 2017, 12:49:59 PM3/23/17
to
"Tristan B. Kildaire" <dea...@disroot.org> writes:
>General question.
>
>A static library is one in which the library's code is put into the
>program's source file and then compiled into a "monolith" executable.

No, a static library is linked with the program's object code
to create a monolith executable.

>
>A dynamic library is one that is not included in the program's source
>code (as in the library's code is not included) but it is loaded during
>some time in the program's execution.

A dynamic library is associated with the programs object code, but not
linked to it until the program is executed.

Christopher Pisz

unread,
Mar 23, 2017, 3:10:27 PM3/23/17
to
The answer is obviously 17.

Christian Gollwitzer

unread,
Mar 23, 2017, 4:08:03 PM3/23/17
to
Am 23.03.17 um 17:41 schrieb Barry Schwarz:
> On Thu, 23 Mar 2017 18:23:02 +0200, "Tristan B. Kildaire"
> <dea...@disroot.org> wrote:
>
>> General question.
>>
>> A static library is one in which the library's code is put into the
>> program's source file and then compiled into a "monolith" executable.
>
> A static library does not have source code. It has object modules.
> They are linked with the programs object modules into a monolithic
> executable which is not affected by any subsequent changes to the
> library.

Maybe it could be mentioned that there is a third kind of a library
especially in the C++ case, the template library, where indeed the
source code is more-or-less copied into the program source. Usually the
program contains in #include for library files from Boos or from the
STL, which is performed by textually inserting the content of the
included file in the source code of the program. A few C libraries also
exist which work in a similar way (using static functions), but this is
mre controversial because for non-template functions this is not necessary.

Christian

Vir Campestris

unread,
Mar 23, 2017, 5:51:52 PM3/23/17
to
Frequently it is loaded before the execution starts. The program header
contains references to libraries that must be loaded, and they in turn
contain references to other libraries.
It's actually unusual in my experience for a program to explicitly load
a dynamic library.

>
> The answer is obviously 17.
>
42, surely?

What was the original question?

Andy

Richard

unread,
Mar 23, 2017, 5:56:03 PM3/23/17
to
[Please do not mail me a copy of your followup]

"Tristan B. Kildaire" <dea...@disroot.org> spake the secret code
<ob0sp7$16tp$1...@gioia.aioe.org> thusly:
This may help:
<https://www.slideshare.net/LegalizeAdulthood/consuming-and-creating-libraries-in-c>
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
0 new messages