LinuxSir.cn,穿越时空的Linuxsir!

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

使用math.h的问题:

[复制链接]
发表于 2005-2-1 22:13:56 | 显示全部楼层 |阅读模式
简单的程序:

#include<math.h>
#include<stdio.h>

int main()
{
  pow(3,3);
}

编译能通过.

但是

#include<math.h>
#include<stdio.h>

int main()
{
  int n=3;
  pow(n,3);
}

就有问题

[root@localhost program]# gcc -o main test2.c
/tmp/cccDOOAE.o(.text+0x3a): In function `main':
: undefined reference to `pow'
collect2: ld returned 1 exit status


不知道怎么搞的,哪位大哥懂得帮忙一下
发表于 2005-2-2 08:59:59 | 显示全部楼层
gcc -o main test2.c -lm
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-2-2 22:42:44 | 显示全部楼层
可以,多谢
-lm代表什么含义啊
回复 支持 反对

使用道具 举报

发表于 2005-2-2 22:54:54 | 显示全部楼层
搜索一下论坛,这个问题已经讨论过多次了.
回复 支持 反对

使用道具 举报

发表于 2005-2-3 08:49:26 | 显示全部楼层
代表数学库libm.so和libm.a
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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