C 调用数学函数pow时遇到 undefined reference [已解决]

1、问题描述
编译如下代码

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

int main()
{
    float x = 2, y = 10;
    float p = 0;

    p = pow(x, y);
    printf("%f
", p);
    
    return 0;
}

出现如下问题
undefined reference to `pow'

2、解决方法
1)man pow

2)在man手册中提到 调用 pow要做两件事,
第一,包含头文件,第二编译时加  -lm
 
3)将数学库链接进来

$ gcc ss.c -o ss -g -Wall -lm
原文地址:https://www.cnblogs.com/aqing1987/p/4313868.html