相关疑难解决方法(0)

未定义的引用`sin`

我有以下代码(根据这个问题的基础知识):

#include<stdio.h>
#include<math.h>

double f1(double x)
{
    double res = sin(x);
    return 0;
}

/* The main function */
int main(void)
{
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

gcc test.c我编译它时,我得到以下错误,我无法解决原因:

/tmp/ccOF5bis.o: In function `f1':
test2.c:(.text+0x13): undefined reference to `sin'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

但是,我编写了各种sinmain函数内部调用的测试程序,并且这些程序完美地工作.我必须在这里做一些明显错误的事 - 但它是什么?

c math linker-errors undefined-reference

90
推荐指数
4
解决办法
13万
查看次数

标签 统计

c ×1

linker-errors ×1

math ×1

undefined-reference ×1