On FreeBSD 10.1
and using Clang version 3.4.1
Now I have seen other threads asking how to compile with using pow(), but I haven't seen a thread with this question. Take for example:
#include <math.h>
#include <stdio.h>
int main()
{
float result;
result = pow(2,3);
printf("%d", result);
return 0;
}
Now using pow()
, I need to issue clang the argument -lm.
cc -lm -o name name.c
However, replacing pow(2,3)
with sqrt(5);
, I can compile with cc -o name name.c
. If they both use math.h
, then why does pow()
need to be linked to the library?
Side not: Installed gcc to test, and I don't need to use -lm at all.