E
Eigenvector
I apologize if this is a trivial question, but it's always made me wonder
when I have to compile my code.
There are some #includes that you don't really need to reference in your
library and header references in the compilation string.
For instance the standard hello.c
#include <stdio.h>
int main()
{
printf("hello world\n");
}
compiles as `cc hello.c -o hello`
Whereas something like this
#include <stdio.h>
#include <math.h>
int main()
{
int x;
x=pow(2,2);
printf("%d\n",x);
}
to compile this you need to reference the math library
`cc math.c -lm -o math`
However, in this 3rd example, I don't have to reference another header file,
even though it isn't ANSI C
#include <stdio.h>
#include <math.h>
#include <unistd.h>
int main()
{
.........................
.....................
.....................
}
Why do you not need to include the reference to the math library for the 2nd
case, but you don't need to reference the stdio header files or the UNIX
headers? More generally, assuming the -lm is a localized compiler
implementation, why would you not reference the math header files like you
would any other external library that you call within your code? If I
wanted to include my own proprietary header files I'd have to give the
compiler a full path, why is the math library different?
when I have to compile my code.
There are some #includes that you don't really need to reference in your
library and header references in the compilation string.
For instance the standard hello.c
#include <stdio.h>
int main()
{
printf("hello world\n");
}
compiles as `cc hello.c -o hello`
Whereas something like this
#include <stdio.h>
#include <math.h>
int main()
{
int x;
x=pow(2,2);
printf("%d\n",x);
}
to compile this you need to reference the math library
`cc math.c -lm -o math`
However, in this 3rd example, I don't have to reference another header file,
even though it isn't ANSI C
#include <stdio.h>
#include <math.h>
#include <unistd.h>
int main()
{
.........................
.....................
.....................
}
Why do you not need to include the reference to the math library for the 2nd
case, but you don't need to reference the stdio header files or the UNIX
headers? More generally, assuming the -lm is a localized compiler
implementation, why would you not reference the math header files like you
would any other external library that you call within your code? If I
wanted to include my own proprietary header files I'd have to give the
compiler a full path, why is the math library different?