|
我的系统是ubuntu-8.10-desktop-amd64,我想用函数sqrt(),但是编译出错.代码如下:
#include <stdio.h>
#include <math.h>
int main()
{
float fn, fres;
double dn, dres;
printf("Enter a float number: " );
scanf("%f", &fn);
fres = sqrtf(fn);
printf("The result of sqrt(%f) = %f\n", fn, fres );
printf("Enter a double number: ";
scanf("%lf", &dn);
dres = sqrt(dn);
printf("The result of sqrt(%lf) = %lf\n", dn, dres );
printf("The result of sqrt(2)=%f\n", sqrt(2) );
}
编译错误:
In function 'main':
trysqrt.c.text+0x51): undefined reference to 'sqrtf'
trysqrt.c.text+0xcc): undefined reference to 'sqrt'
我查看了/usr/include/math.h头文件,但是找不到sqrt()函数声明,请问这是怎么回事? |
|