“对‘pow’的未定义引用”是什么意思?

Pro*_*ker -1 c linux math.h visual-studio pow

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

main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    double ans= pow(a,b);
    printf("%f",ans);
    
}
Run Code Online (Sandbox Code Playgroud)

我写了这段代码并尝试在 Visual stdio (linux) 中运行。但它给出了一条错误消息

味精- new_year_candles.c:4:1: warning: return type defaults to ‘int’ [-Wimplicit-int] 4 | main() | ^~~~ /usr/bin/ld: /tmp/ccCQbbLV.o: in function `main': new_year_candles.c:(.text+0x4a): undefined reference to `pow' collect2: error: ld returned 1 exit status

现在做什么?

小智 5

用链接编译-lm,比如

gcc -o demo demo.c -lm

如果你看看powman

在此处输入图片说明