|

楼主 |
发表于 2005-3-20 20:24:39
|
显示全部楼层
Post by leros_H
这个不关事!不是没装什么软件的关系!
问题的解决也是很简单的!
你在用下面的命令来编译
gcc *.c -lm
这个函数的库要自己手动连接的!
为什么哩,看看这个sqrt的man手册中有这样一句话:
Link with -lm
就是说编译时要手动连接库。
其他的函数也会在man手册里有说明的!
问题解决了,兄弟说得很正确。果然编译通过了。
不过,在我的fedora 3上的man 文档上根本就没有提到 link with -lm这句话。
是不是有些linux发行版的man文档也有些不一样?
以下是我机子上的sqrt的man文档的全文
SQRT(3) Linux Programmer<E2><80><99>s Manual SQRT(3)
NAME
sqrt, sqrtf, sqrtl - square root function
SYNOPSIS
#include <math.h>
double sqrt(double x);
float sqrtf(float x);
long double sqrtl(long double x);
DESCRIPTION
The sqrt() function returns the non-negative square root of x. It
fails and sets errno to EDOM, if x is negative.
ERRORS
EDOM x is negative.
CONFORMING TO
SVID 3, POSIX, BSD 4.3, ISO 9899. The float and the long double vari-
ants are C99 requirements.
SEE ALSO
hypot(3)
2002-07-27 SQRT(3)
~
~
(END) |
|