LinuxSir.cn,穿越时空的Linuxsir!

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

A fool question.

[复制链接]
发表于 2004-10-10 10:13:12 | 显示全部楼层 |阅读模式
I am new with linux.There're some trouble with my first program.Can Anyone give me some clue?
::::
#include<stdio.h>
#include<math.h>

int main(void)
{
        double pi=M_PI;
        double pisqrt;
        long i;

        for (i=0;i<10000000;++i)
        {
                pisqrt = sqrt(pi);
        }
        return 0;
}

The erro message is"
/tmp/ccr8tIwR.o(.text+0x3c): In function `main':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
"
What's the matter?
发表于 2004-10-10 10:34:54 | 显示全部楼层
gcc a.c -o a -lm
告诉编译器要连接数学库
 楼主| 发表于 2004-10-10 10:44:36 | 显示全部楼层

Thanks

It works.
Thank you,I just want to kiss you.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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