I had a code that was working perfectly in windows but when i tried to compile it in linux i got an error. I found that the issue is with the sin()
function.
If i pass to it a constant number directly, it works fine:
#include <stdio.h>
#include <math.h>
int main(void) {
float y = sin(1.57);
printf("sin(1.57) = %f", y);
return 0;
}
sin(1.57) = 1.000000
But when i pass to it a variable i get an error:
#include <stdio.h>
#include <math.h>
int main(void) {
float x = 1.5;
float y = sin(x);
printf("sin(%f) = %f", x, y);
return 0;
}
/tmp/ccfFXUZS.o: In function `main':
source-bcfaa9ff162b:(.text+0x1a): undefined reference to `sin'
collect2: error: ld returned 1 exit status