View Full Version : weird errors gcc: functions like floor(), ceil(), sqrt()

06-04-2005, 08:24 AM

I just recently started working in linux red hat 9.0 to compile my C programs , I am using the gcc command but the program is giving me weird errors and does not recognize the functions ceil(), floor() and sqrt(), I have tried and added most header files like math.h nad stdlib.h along with stdio.h but I keep getting wried errors like :

/tmp/ccqz1JFE.o(.text+0xba): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status

The program is as follows


int main()
double i, j, k;
for(j = 0.0; j < 1.0; j += 0.1)
printf("%8.1f", j);
for(i = 0.0; i < 10.0; i += 1.0)
for(j = 0.0; j < 1.0; j += 0.1)
k = i + j;
printf("%8.1f", sqrt(k));
return 0;

06-04-2005, 08:28 AM
Don't cross-post, it's rude. A lot of us read all of the forums, so cross-posting will likely be counter productive. Instead of getting you a faster response, we might just ignore you.

06-04-2005, 08:39 AM