On FreeBSD 10.1 and using Clang version 3.4.1
Now I saw other topics asking how to compile with pow () , but I did not see 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 give clang the -lm argument.
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 do pow() need to be linked to the library? Not side: gcc is installed for testing, and I don't need to use -lm at all.
Webtm source share