我是C语言的新手,经常遇到同样的错误。我在nano文本编辑器中输入代码,并在Linux终端中编译。我的操作系统是Ubuntu 14.04。以下是一个无法编译的代码示例:
#include <math.h>
#include <stdio.h>
int main()
{
float x = 23.33f;
x = roundf(x);
printf("%f\n", x);
return (0);
}
我收到的错误是:
cc example.c -o example
/tmp/ccWV0Or8.o: In function `main':
example.c:(.text+0x1d): undefined reference to `roundf'
collect2: error: ld returned 1 exit status
make: *** [example] Error 1
非常感谢您的帮助!