PDA

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



gemini_shooter
06-04-2005, 08:24 AM
hi!

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



#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
double i, j, k;
for(j = 0.0; j < 1.0; j += 0.1)
printf("%8.1f", j);
printf("\n");
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));
}
printf("\n");
}
return 0;
}

Prelude
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.

sean
06-04-2005, 08:39 AM
http://cboard.cprogramming.com/showthread.php?t=66243