compiler errors - undefined reference to `roundf' - C language -
i'm new c , keep running same error. typing code in nano text editor , compiling in linux terminal. operating system ubuntu 14.04. here's example of code won't compile,
#include <math.h> #include <stdio.h> int main() { float x = 23.33f; x = roundf(x); printf("%f\n", x); return (0); }
the error receiving is,
cc example.c -o example /tmp/ccwv0or8.o: in function `main': example.c:(.text+0x1d): undefined reference `roundf' collect2: error: ld returned 1 exit status make: *** [example] error 1
any appreciated, thanks!
link math library:
cc example.c -o example -lm
the math library functions not part of standard c library linked default. need link yourself.
there's interesting thread why it's not part of libc:
Comments
Post a Comment