#include <math.h> does not work
I just did a clean install of Mandrake 10.0 Official. All works fine except when I go to compile a simple c program including math.h. The compile completes and then I get a ld error:
[jerry@localhost practice]$ gcc divide.c -o divide /home/jerry/tmp/ccKo59RF.o(.text+0x8c): In function `main': : undefined reference to `sinf' collect2: ld returned 1 exit status I first noticed when trying to compile a simple benchmark program and it would not go. Here is code for divide.c. I am just printing the sine of PI. #include <stdio.h> #include <math.h> #define LIMIT 1000 #define PI 3.14159 int main(void) { int i, j, result; float num; for(i=0;i<LIMIT;i++) { for(j=1;j<10;j++) { printf("%d / %d = %d R %d.\n",i,j, i/j, i%j); } } num=sinf(PI); printf("Thats all folks!\n"); printf("The sin of 1.5 is: %f\n", num); return(0); } any suggestions anyone? |
Try
Code:
[jerry@localhost practice]$ gcc -lm divide.c -o divide |
That was it. I have to confess I feel a bit stupido after that one :)
|
All times are GMT -5. The time now is 01:39 AM. |