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 中对函数未定义引用