gcc 中对函数未定义引用_错误-在GCC Linux中使用C程序未定义对'pow'的引用

gcc 中对函数未定义引用

在Linux中修复对'pow'的未定义引用 (Fixing undefined reference to 'pow' in Linux)

This is a common error while compiling C program in GCC/G++ Linux. This error occurs when you are using pow function to calculate power of a number in your programs.

这是在GCC / G ++ Linux中编译C程序时的常见错误。 当您使用pow函数计算程序中数字的幂时,会发生此错误。

要解决此问题,请确保以下几点: (To fix this problem ensure following points:)
  • Include header file math.h in your program.

    在程序中包含头文件math.h。

  • Add –lm linker flag with compilation command.

    用编译命令添加–lm链接器标志。

1-包括头文件 (1- Include Header file)
    #include <stdio.h>
    #include <math.h>
    ...
    ...

2-编译命令 (2- Compile command)
    gcc  main.c -o main -lm

To more explanation : Compiling C program with math.h library in Linux.

更多说明: 在Linux中使用math.h库编译C程序。

翻译自: https://www.includehelp.com/c-programming-questions/error-undefined-reference-to-pow-in-linux.aspx

gcc 中对函数未定义引用

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值