I am trying to use the sqrt() function that, according to all the help and tutorials I have read, should be included with the #include <math.h> call. This does not seem to be the case as I have tried to compile a bit of source code on two different machines and both of the have failed due to sqrt() being an undefined function. The code snipit looks like this:
#include <stdio.h>
#include <math.h>
char input[80];
float ...;
double distSqr, dist;
int main()
{
...
dist = sqrt(distSqr);
...
return(0);
}
My compile line looks like this:
gcc -g -Wall -ansi -pedantic -odist dist.c
And the error I get is:
/tmp/ccY4jY7J.o: In function `main':
/home/.../dist.c:19: undefined reference to `sqrt'
collect2: ld returned 1 exit status
I have browsed the math.h file but I see no reference to the sqrt() function, could someone please help me. I am going to loose it!
Thanks
-Jayson
#include <stdio.h>
#include <math.h>
char input[80];
float ...;
double distSqr, dist;
int main()
{
...
dist = sqrt(distSqr);
...
return(0);
}
My compile line looks like this:
gcc -g -Wall -ansi -pedantic -odist dist.c
And the error I get is:
/tmp/ccY4jY7J.o: In function `main':
/home/.../dist.c:19: undefined reference to `sqrt'
collect2: ld returned 1 exit status
I have browsed the math.h file but I see no reference to the sqrt() function, could someone please help me. I am going to loose it!
Thanks
-Jayson