小编Yuc*_* Li的帖子

C程序编译错误:未定义的引用

我无法编译以下简单的C代码,我不知道为什么.

#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
int main(){
     double result;
     result = cos(0.5);
     printf("asin(0.5) is %f\n", result);
     return 0;
}
Run Code Online (Sandbox Code Playgroud)

我尝试编译后收到的错误消息是 -

In function 

'main':
test.c:(.text+0xlc): undefined reference to 'cos'
collect2: ld

 returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

c gcc

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

标签 统计

c ×1

gcc ×1