Try gcc -lm <program.c>. 

-Karthik.

On Tue, 20 Jun 2000, at 3:05pm, Madhav wrote:

> Hi all,
>     I have a problem compiling this simple program in gcc under my RH linux
> 6.1. I am giving it here.
> 
> #include <math.h>
> #include <stdio.h>
> main()
> {
> double i,n;
> n=0;
> for (i=0;i<100;i++)
> n += sqrt (i);
> printf("the sum of square roots of first 100 natural numbers=%f",n);
> }
> 
> is giving an error "undefined reference to 'sqrt' ".  Can anybody tell me
> what the problem may be?
> 
> thanks in advance,
> Madhav
> 
> 
> 

Reply via email to