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

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

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

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

 

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

2、解决方法
1)man pow

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

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

$ gcc ss.c -o ss -g -Wall -lm

相关文章:

  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2021-04-20
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案