为什么以下代码向我抛出错误 undefined reference to sqrt。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
double i = 25;
printf("\nSquare root of %d = %d",i,sqrt(i));
return 0;
}
我已经包含了 math.h 并且我正在使用 Debian。谁能告诉我哪里出了问题。我需要重新安装我的库还是什么?
最佳答案
在命令行上使用 -lm 标志编译它以链接到数学库。
关于c - C 中的 math.sqrt 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5711902/