我似乎无法使用pow() [英] I can't seem to use pow()

查看:83
本文介绍了我似乎无法使用pow()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在fedora 3系统上使用gcc这里我认为相关的

行是:


#include< math。 h>


[一堆东西剪断]


r = pow(2,z);


编译时我得到


/tmp/ccg0U2N1.o(.text+0xd9):在函数`generateMap''中:

:undefined引用'pow''

collect2:ld返回1退出状态


为什么会这样?


- -

Mark Healey

marknews(at)healeyonline(dot)com

I''m using gcc on a fedora 3 system here are what I think the relevant
lines are:

#include <math.h>

[a bunch of stuff snipped]

r=pow(2,z);

When I compile I get

/tmp/ccg0U2N1.o(.text+0xd9): In function `generateMap'':
: undefined reference to `pow''
collect2: ld returned 1 exit status

Why is this?

--
Mark Healey
marknews(at)healeyonline(dot)com

推荐答案

Mark Healeyaécrit:
Mark Healey a écrit :
我在fedora 3系统上使用gcc这里我认为相关的
行是:

#包括< math.h>

[一堆东西剪断]

r = pow(2,z);

当我编译我得到

/tmp/ccg0U2N1.o(.text+0xd9):在函数`generateMap''中:
:对`pow的未定义引用'
collect2:ld返回1退出状态

为什么会这样?
I''m using gcc on a fedora 3 system here are what I think the relevant
lines are:

#include <math.h>

[a bunch of stuff snipped]

r=pow(2,z);

When I compile I get

/tmp/ccg0U2N1.o(.text+0xd9): In function `generateMap'':
: undefined reference to `pow''
collect2: ld returned 1 exit status

Why is this?



因为那个愚蠢的编译器默认不包含C库。

由用户自行决定是否包含它,以及那些没有b $ b经验的人。使用那个编译器,它将是一个发现....


gcc myprog.c -lm


那个神秘的-lm意味着包括数学库,包括pow,cos等。


它们永远不会改变那个拦截的特征。我们将不得不听到

这种抱怨直到时间结束。


Because that stupid compiler doesn''t include the C library by default.
It is up to the user to include it, and for people that do not have
"experience" with that compiler it will be a discovery....

gcc myprog.c -lm

That cryptic "-lm" means include the math library, include pow, cos, etc.

They will never change that dammed "feature" and we will have to hear
this kind of complaints till the end of times.


Mark Healey< di*@spammer.die>写道:
Mark Healey <di*@spammer.die> writes:
我在fedora 3系统上使用gcc这里我认为相关的
行是:

#include< math.h> ;

[一堆东西剪断]

r = pow(2,z);

当我编译时我得到

/tmp/ccg0U2N1.o(.text+0xd9):在函数`generateMap'':
:未定义引用`pow''
collect2:ld返回1退出状态

为什么会这样?
I''m using gcc on a fedora 3 system here are what I think the relevant
lines are:

#include <math.h>

[a bunch of stuff snipped]

r=pow(2,z);

When I compile I get

/tmp/ccg0U2N1.o(.text+0xd9): In function `generateMap'':
: undefined reference to `pow''
collect2: ld returned 1 exit status

Why is this?




< http://www.c-faq.com/fp/libm.html>


-

Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



<http://www.c-faq.com/fp/libm.html>

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


Mark Healey写道:
Mark Healey wrote:
我在fedora 3系统上使用gcc这里是我的想法相关的
行是:

#include< math.h>

[一堆东西剪断]

r = pow(2,z);

当我编译时,我得到

/tmp/ccg0U2N1.o(.text+0xd9):在函数`generateMap'':
:undefined引用`pow''
collect2:ld返回1退出状态

为什么会这样?
I''m using gcc on a fedora 3 system here are what I think the relevant
lines are:

#include <math.h>

[a bunch of stuff snipped]

r=pow(2,z);

When I compile I get

/tmp/ccg0U2N1.o(.text+0xd9): In function `generateMap'':
: undefined reference to `pow''
collect2: ld returned 1 exit status

Why is this?



你还没有在数学库中链接。这让你成为C的新人。

那个新的,你是怎么找到这个新闻组的?


请你在再次发帖之前阅读这些内容。 。

http://c-faq.com


-

Joe Wright

所有事情都应尽可能简单,但并不简单。

---阿尔伯特爱因斯坦---


You haven''t linked in the math library. That makes you new to C. Being
that new, how did you find this newsgroup?

Please, before you post again, read the stuff at..

http://c-faq.com

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---


这篇关于我似乎无法使用pow()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆