LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 597|回复: 3

菜鸟问题

[复制链接]
发表于 2004-7-11 11:48:10 | 显示全部楼层 |阅读模式
我是刚学编程的,有个问题:
/*----sqrt.c------*/
#include<stdio.h>
#include<math.h>
main()
{
float a,b;
printf("Enter a value for a:\n");
scanf("%f",&a);
b=sqrt(a);
printf("The result is %f.\n",b);
}

[txw@TCL txw]$ cc -o sqrt sqrt.c
/tmp/cc8Z2pIW.o(.text+0x42): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
[txw@TCL txw]$

难道gcc里没有sqrt()吗?????
发表于 2004-7-11 14:55:28 | 显示全部楼层
用cc -o sqrt sqrt.c -lm编译。
发表于 2004-7-13 17:14:04 | 显示全部楼层

lm是什么意思?

请问斑竹,-lm参数是什么意思啊?谢谢:)
发表于 2004-7-13 18:13:38 | 显示全部楼层
链接数学库
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表