POW()没有被定义 [英] pow() isn't defined

查看:758
本文介绍了POW()没有被定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

void main()
{
    int i, d, sum = 0, a = 6, b = 2;

    for(i = 0; i <= 4; i++)
    {
        d = a - b;
        sum += pow(d, i);
    }

    printf("%d", sum);
}

每当我试图执行这个程序,错误消息只是弹出说:

Whenever I am trying to execute this program, an error message just pops up saying:

在功能:结果
  未定义的引用 POW

我究竟在这里失踪?

推荐答案

这是一个连接失败。你需要用数学库 -lm 在你的编译器命令的末尾链接,指定。从人POW

This is a linker failure. You need to link with the math library, specify -lm at the end of your compiler command. From man pow:

链接与-lm。

这篇关于POW()没有被定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆