By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <11**********************@o13g2000cwo.googlegroups .com>,
<sa***********@yahoo.com> wrote:
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.
--
Chocolate is "more than a food but less than a drug" -- RJ Huxtable
Nov 15 '05 #2

P: n/a

<sa***********@yahoo.com> wrote
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.
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.