Originally Posted by
JayCee++
However I cannot get my head round libraries and in particular where they are stored
Libraries are compiled executable files. Where they are stored depends on your OS. They may be static or dynamic, aka. shared.
When you compile your own programs, any static libraries it needs are compiled right into it by the linker. Ie, the linker finds the library and copies it in. On most modern OS's, this is considered inefficient and wasteful, so instead of linking in static libraries, your exe is linked to a shared library. Then, at runtime, the dynamic linker manages the relationship between your program and the shared libraries it is linked to.
The source for C/C++ libraries are normal looking code, defining functions, types, classes, etc, but usually without a main(), because the library does not do anything by itself. It just provides functions, types, classes, etc.
and how you know what is in each and suchlike.
That's what the header files are for; they contain function prototypes, type declarations, etc. The compiler needs that. As for the programmer, you can read the header (where they are depends on the system; on linux mostly /usr/include), but hopefully the library also has some more user friendly documentation.
A library can have more than one header file. The C++ standard library could be organized a lot of different ways as determined by the OS design, but (AFAIK) it is usually just one big shared executable file (including the STL...?). Most of the time you are only using a subset of the available features, and you include the appropriate headers, eg:
Code:
#include <iostream>
#include <string>
Those are headers. There is not actually a "iostream" library, it is part of the C++ standard library. There's just the iostream header.
You might want to read this thread from a few days ago too:
header files