This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re:- gcc sqrt function
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: Re:- gcc sqrt function
- From: Ted <ted at hardwicke dot co dot uk>
- Date: Thu, 21 Oct 1999 15:49:24 +0100
Dear Sirs,
I am sorry to trouble you with this query, since my problems may be due
to ignorance on my part.
I am starting to learn how to program in C, and I am having problems
using the `sqrt' function.
I am using a PII PC running Redhat 6.0 Linux.
The version of gcc is:- egcs-2.91.66 19990314/Linux
The math.h header file is present in the `/usr/include' directory.
The following file is taken from `Teach Yourself C' by Schildt, page
27:-
/************************************************************/
#include <stdio.h>
#include <math.h>
int main(void)
{
double answer;
answer = sqrt(10.0);
printf("%f", answer);
return 0;
}
/************************************************************/
When I try to compile this with the command:-
`gcc -g -Wall -osqrt sqrt.c'
I get the error message:-
`8: undefined reference to `sqrt.'
`collect2: ld returned 1 exit status'
Is there a bug in gcc, or am I not using the function correctly? I have
searched through the gcc info file, but I can't seem to find a solution.
Many thanks in anticipation.
Ted Mason