Re: I can't seem to use pow()



Joe Wright <joewwright@xxxxxxxxxxx> writes:
Mark Healey wrote:
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?

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

Or he's been using compilers that link the math library without being
told to do so. Or he hasn't been using <math.h> until recently.

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

http://c-faq.com

To be fair, that particular question can be difficult to find unless
you already know about it. The question refers to "sin" and "cos",
not to "pow". (On the other hand, it also refers to <math.h>, and
it's in the section on floating point, so it's not *completely*
hidden.)

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <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.
.



Relevant Pages