public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Looking for pow function in C
@ 2003-12-03 18:52 tonibin
  2003-12-03 18:54 ` Ian Lance Taylor
  2003-12-03 18:55 ` Janos Murvai
  0 siblings, 2 replies; 3+ messages in thread
From: tonibin @ 2003-12-03 18:52 UTC (permalink / raw)
  To: gcc-help

Dear gcc team:

I'm a C programmer, and I use gcc. Recently I upgraded my Linux box to 
RedHat 9A.

Starting a C project, everything went ok until I did a math operation.

I included <math.h>, and executed a simple pow(x1,x2) function, with x1 
and x2 of type double.

The compiler reports:

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

The #include <math.h> is regular.

What's the problem? I'm sure that the gcc package is installed correctly, 
but grepping the /usr/include directory, no file with the pow definition 
seem to exist. And even log, log10 and exp seem to have vanished.

Any help?

Thank you.

Version used:
gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)


-- 
Antonio Maschio
<tbin@libero.it>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Looking for pow function in C
  2003-12-03 18:52 Looking for pow function in C tonibin
@ 2003-12-03 18:54 ` Ian Lance Taylor
  2003-12-03 18:55 ` Janos Murvai
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2003-12-03 18:54 UTC (permalink / raw)
  To: tonibin; +Cc: gcc-help

tonibin@libero.it writes:

> /tmp/cctlMXxf.o(.text+0x948): In function `parseString':
> : undefined reference to `pow'

You need to link against the math library by using -lm, as in:
    gcc -o foo foo.o -lm

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Looking for pow function in C
  2003-12-03 18:52 Looking for pow function in C tonibin
  2003-12-03 18:54 ` Ian Lance Taylor
@ 2003-12-03 18:55 ` Janos Murvai
  1 sibling, 0 replies; 3+ messages in thread
From: Janos Murvai @ 2003-12-03 18:55 UTC (permalink / raw)
  To: tonibin; +Cc: gcc-help


Please use -lm

gcc c_prog.c -lm -o c_prog

Janos

On Wed, 3 Dec 2003 tonibin@libero.it wrote:

> Dear gcc team:
>
> I'm a C programmer, and I use gcc. Recently I upgraded my Linux box to
> RedHat 9A.
>
> Starting a C project, everything went ok until I did a math operation.
>
> I included <math.h>, and executed a simple pow(x1,x2) function, with x1
> and x2 of type double.
>
> The compiler reports:
>
> /tmp/cctlMXxf.o(.text+0x948): In function `parseString':
> : undefined reference to `pow'
> collect2: ld returned 1 exit status
>
> The #include <math.h> is regular.
>
> What's the problem? I'm sure that the gcc package is installed correctly,
> but grepping the /usr/include directory, no file with the pow definition
> seem to exist. And even log, log10 and exp seem to have vanished.
>
> Any help?
>
> Thank you.
>
> Version used:
> gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
>
>
> --
> Antonio Maschio
> <tbin@libero.it>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-03 18:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-03 18:52 Looking for pow function in C tonibin
2003-12-03 18:54 ` Ian Lance Taylor
2003-12-03 18:55 ` Janos Murvai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).