小编B. *_*age的帖子

未定义的引用`roundf' - C语言

我是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);
    }
Run Code Online (Sandbox Code Playgroud)

我收到的错误是,

    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
Run Code Online (Sandbox Code Playgroud)

非常感谢任何帮助,谢谢!

c compiler-errors compilation math.h ubuntu-14.04

1
推荐指数
1
解决办法
4436
查看次数

标签 统计

c ×1

compilation ×1

compiler-errors ×1

math.h ×1

ubuntu-14.04 ×1