What is "shared library" in C, is there any small example I can see?

S

santa19992000

Confusing th eword with "library", "shared library" and how to use
these things in real C project, is there any small example I can take a
look. Thanks.
 
W

Walter Roberson

Confusing th eword with "library", "shared library" and how to use
these things in real C project, is there any small example I can take a
look. Thanks.

The C language itself does not have "library" or "shared library"
or "project". The C standard requires that the implementation provide
a standard set of routines which it calls "the standard library",
but the C standard puts no restriction on how the implementation
does that.

It is -common- for implementations to provide ways of bundling
groups of half-compiled programs, and that those bundles can
be referenced by the linking phase in order to provide access
to the routines and data, but there is a fair variability in
how that is done.

A "shared library" (in common parlance) is just another
library (with system-dependant semantics and invocation
mechanisms). Again the C standard has nothing to say on
the matter.

When a system bothers to distinguish between a "library"
and a "shared library", it might commonly be saying that
only one copy of the "shared library" will be placed in memory
for access by all users and all processes, whereas a library
on such a system that was -not- "shared" would have a copy of
some or all of it placed into each process's address space.

Details of what a "library" or "shared libary" mean on your
system, and how to use them, should be asked about in a newsgroup
appropriate for your system. As I mentioned before, they are not
C concepts as such, and there are important differences between
different systems.
 
M

Malcolm

Confusing th eword with "library", "shared library" and how to use
these things in real C project, is there any small example I can take a
look. Thanks.
Most C implentations allow you to build "libraries" - compiled function
which can be called from user code. The standard library and extensions will
probably come with the compiler as "library" files.

On a big system, exactly what some of these libraries do can be complex. For
instance a sophisticated operating system won't want printf() writing pixels
directly to the screen, it will want facilities for capturing and
redirecting output, changing fonts, providing braile access for blind users,
and so. Also it doesn't make any sense to load a huge system for one "hello
world" program - better have all the code resident in memory.

Exactly what "shared library" menas can differ, however, as Walter pointed
out. It could mean a libary which more than one application links to, it
could mean a library of which only one copy is in memory at any one time, it
could mean a library like the braile printf example which several programs
access simulataneously in a cooperative manner.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top