On Thu, Feb 21, 2002 at 02:57:58PM -0500, Trond Eivind Glomsrød wrote: > No, it only declares the symbols and functions. A header file does not > specify linking. > > > Out of curiosity is there a way to compile without specifying -lm? > > > > Just wondering why -lm is required for standard math functions. > > Because libm contains the standard math functions.
A bit more explanation--although this isn't specifically RedHat, or even Linux, so it should be on a software development list...so the following is necessarily simplified. But it should dispell some misconceptions I think I see. A program consists of code that is compiled from source into machine executable instructions. If you had to rebuild all source every time you tried to build the program, the development process would be exceedingly time-consuming and tedious; and usually, changes are only to a small portion of the code at any given time. Therefore, it's desirable to do this in stages. Thus, it's possible to compile portions--usually segregated in separate source files--of the program into an intermediate form called an object file. A program called the 'linker' then can combine these intermediate object files into a functioning executable file. When components of the program are separated in this manner, header files provide information about the other portions of the program--such as valid function names, values for arguments, etc.--that need to be used to reference these in the source of any given element. The intermediate object files contain these _external_ references in a form recognizable to the 'linker', which can then reconcile them all when it constructs the final executable. Much code is common--for instance, math functions--and doesn't change between different programs that use it. Thus, common functions are compiled into intermediate object form, and the resulting files are grouped together in an object library for convenience. The linker knows how to select just the objects it needs from the library. That's about as simplified as I can make it, but I hope it helps. -- Dave Ihnat [EMAIL PROTECTED] _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list