lewisforlife
November 27th, 2009, 04:02 PM
I need a little clarification with gcc. Lately I have been playing around with some C programming. I am using gcc to compile my programs. I am having trouble knowing what parameters to add to gcc when compiling. For instance, if I am compiling a program that includes math.h I have to do
gcc -o mathprog math.c -lm
I don't understand why the "-lm" has to be added to the compiler, why can't it just read math.h. So, do I have to add a parameter to gcc for every header file I include in the C program? If so, is there a list with all of these parameters. For instanance, if I include something.h, how will I know what parameter to add, is it, gcc -lsomething, or gcc -ls. Is there a list with all of the header files and what -l to add in the gcc code?
Also, what does gcc -Wall do, I notice a lot of examples use -Wall but there is no explanation of what this does?
gcc -o mathprog math.c -lm
I don't understand why the "-lm" has to be added to the compiler, why can't it just read math.h. So, do I have to add a parameter to gcc for every header file I include in the C program? If so, is there a list with all of these parameters. For instanance, if I include something.h, how will I know what parameter to add, is it, gcc -lsomething, or gcc -ls. Is there a list with all of the header files and what -l to add in the gcc code?
Also, what does gcc -Wall do, I notice a lot of examples use -Wall but there is no explanation of what this does?