Libraries are collections of object files; i.e., a function written in, say, C, that is compiled to an object file (a "dot.o") then inserted with other object files in a searchable file (called a library) where it or they may be extracted for use by a program at run time. Keep in mind that there are library files for other compiled languages (such as FORTRAN) which are used in the same way.
An example would be the basic
hello_world program. In C, that would be
Code:
main ()
{
printf ("Hello, world\n");
}
(that's as stripped down as it can get and not really the recommended way to code or good practice but it's just for example purposes).
The
printf() function is one of the object files in a library file named
libc;
libc will be
libc.so (dynamic) or
libc.a (static). Same source code, different library file structure. Too,
printf() does not stand alone, it calls a number of other functions (in
libc) to actually put
Hello, world on a terminal window. See the
man page for the
ld program for more detail about how this is done.
Modules are also functions (in the C sense) that dynamically are loaded or unloaded by the kernel as needed. The kernel can be built statically where only the drivers for a particular hardware set are compiled in (rather than compiled as modules).
So, yes, you've got it pretty much right; wouldn't hurt to browse though the manual pages, including the
SEE ALSO section at the bottom of manual pages for related information. The
gcc manual page might be a good place to start.
How should
helo_world.c really look (so the compiler doesn't yammer at you)?
Code:
#include <stdio.h>
int main (void)
{
printf ("Hello, world\n");
}
Not much more there, but it's cleaner.
Hope this helps some.