This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Trying to learn C on the gcc compiler
- To: gcc at gcc dot gnu dot org
- Subject: Trying to learn C on the gcc compiler
- From: Kelly Schauf <k3jsch at mail dot gmtcom dot com>
- Date: Mon, 5 Jun 2000 08:39:09 -0500 (CDT)
To the forum:
I have been using the gcc compiler as a tool for learning C, and I am
having problems compiling the following simple program:
#include <stdio.h>
#include <stdlib.h>
#include <math.h> /* Include file for sqrt () */
int main( void )
{
double num;
printf( "Enter a non negative number: " );
/* The %lf conversion specifier indicates a
*data object of type double
*/
scanf( "%lf", &num);
if (num < 0)
printf( "Input Error: Number is negative.\n" );
else
printf( "The Square root is: %f\n", sqrt( num ));
exit( 0 );
}
The error that I get is "undefined reference to sqrt".
Any ideas? Thanks in advance.
Kelly Schauf