Sample code for fmod
#include <stdio.h>
#include <math.h>
int main(void)
{
double x = 0.14527, y = 3.14159;
printf("fmod(x, y) = %.6lf\n", fmod(x, y));
return 0;
}
$ gcc main.c -o main
I get
/tmp/ccztJO01.o: In function `main':
main.c:(.text+0x4d): undefined reference to `fmod'
collect2: ld returned 1 exit status
then, i ask help from Google,
i found the answer,
$ gcc -lm main.c -o main
Why should i use -lm, what is it exactly. From where i can get more information about gcc in detail. Please guide me in this issue.