> lcd.c:126: undefined reference to `cos'

This is definitely a missing libm.

> Even if i include "math.h" with or not -lm compilation parameters

"-lm" works for me, as expected:

  ostro% cat > /tmp/trig.c
  int main(int argc, char **argv) {return sin(atof(argv[1]));}
  ^D
  ostro% gcc /tmp/trig.c -o /tmp/trig
  /tmp/cc6DCmZH.o(.text+0x2c): In function `main': undefined reference to `sin'
  collect2: ld returned 1 exit status
  Exit 1
  ostro% gcc -lm /tmp/trig.c -o /tmp/trig
  ostro%

But please note that some toolchains require "-lm" to go last (i.e., _after_
the source or object file where the undefined symbol is encountered).

/alessandro

Reply via email to