The following code is throwing undefined symbol error on Linux.
$ cat rms.c
/* sqrt example */
#include <stdio.h>
#include <math.h>
int main ()
{
double param, result;
param = 1024.0;
result = sqrt (param);
printf ("sqrt(%lf) = %lf\n", param, result );
return 0;
}
$ gcc rms.c
/tmp/ccaWecFP.o(.text+0x24): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
If I replace argument to sqrt() with (double)16 then program is compiling and executing. Why is this throwing error in first case.