Mail Archives: djgpp/1999/11/18/07:10:47
Heya
Well, on the same point, what about libraries that call other libraries?
I'm busy coding a set of image processing functions that run on top of Allegro...
If I compile these functions into a library, will it include Allegro's library
*into* my library or will it remain external whereas I just include both
libraries on the command prompt?
- Michael
Davin McCall wrote:
> On Wed, 17 Nov 1999 18:38:10 -0600, "Morpheus" <hall AT cs DOT unt DOT edu>
> wrote:
>
> >I know the difference between a library file and a header file, but can
> >someone tell me the particulars involved -- the differences between
> >compiling your program with included headers and including a library on the
> >prompt? I know the header files on the include path don't contain a full
> >implementation of their functions/classes, so where is this implementation?
>
> In a library file.
>
> >If it's in the library files, how does the compiler know which library to
> >get without specifying it at the prompt?
>
> It generally doesn't. In the case of the "standard headers" (eg
> stdio.h, stdlib.h, string.h), the implementations are contained in the
> standard library, which is automatically linked in (you don't need to
> specify it on the command line). For other headers, you generally also
> need to specify the library file.
>
> > If compiling with libraries and
> >headers are independent things, then what is the advantage of compiling with
> >library files?
>
> Hopefully you understand by now, but to further clarify: Including
> headers and linking libraries are not completely independent: They
> supplement each other.
>
> In particular, the header file tells the compiler what functions (and
> variables and types etc) are available in the library, so that it
> knows how many arguments each of the functions takes and can generate
> appropriate errors if the wrong number is used, etc.
>
> The library on the other hand contains the implementation, which is
> pre-compiled code. The linker uses the library file by extracting the
> appropriate code and including it in the program (incidentally, the
> compiler calls the linker automatically, and passes the appropriate
> library files as specified by the user. It also adds the standard
> library at this point).
>
> Davin.
- Raw text -