Message-ID: <383394B1.85C36040@snetch.cpg.com.au> Date: Thu, 18 Nov 1999 16:54:58 +1100 From: Michael Abbott aka frEk <20014670 AT snetch DOT cpg DOT com DOT au> Organization: Student of Computer Power Institute X-Mailer: Mozilla 4.05 [en] (Win95; I) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: difference between libraries and headers References: <80vhq4$kvc AT hermes DOT acs DOT unt DOT edu> <38335d9f DOT 2707933 AT newsserver DOT cc DOT monash DOT edu DOT au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com 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" > 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.