There is no pow()

View: New views
5 Messages — Rating Filter:   Alert me  

There is no pow()

by beradero :: Rate this Message:

| View Threaded | Show Only this Message

Why there is no pow() function on my /usr/include/math.h ?
 
# cat /usr/include/math.h | grep pow
#                    /*      Nothing      */

Re: There is no pow()

by Andreas Jaeger :: Rate this Message:

| View Threaded | Show Only this Message

beradero <tessiof@...> writes:

> Why there is no pow() function on my /usr/include/math.h ?
>  
> # cat /usr/include/math.h | grep pow
> #                    /*      Nothing      */

Check the include files that math.h includes,

Andreas
--
 Andreas Jaeger, Director Platform / openSUSE, aj@...
  SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
   Maxfeldstr. 5, 90409 Nürnberg, Germany
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


attachment0 (199 bytes) Download Attachment

Re: There is no pow()

by beradero :: Rate this Message:

| View Threaded | Show Only this Message

There is not..
When I try to compile this simple program (pow.c), gcc tels me: "undefined reference to 'pow'"

Andreas Jaeger wrote:
beradero <tessiof@yahoo.com.br> writes:

> Why there is no pow() function on my /usr/include/math.h ?
>  
> # cat /usr/include/math.h | grep pow
> #                    /*      Nothing      */

Check the include files that math.h includes,

Andreas
--
 Andreas Jaeger, Director Platform / openSUSE, aj@suse.de
  SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
   Maxfeldstr. 5, 90409 Nürnberg, Germany
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

 
pow.c

Re: There is no pow()

by Andreas Jaeger :: Rate this Message:

| View Threaded | Show Only this Message

beradero <tessiof@...> writes:

> There is not..
> When I try to compile this simple program (pow.c), gcc tels me: "undefined
> reference to 'pow'"

That's a different problem - you have to pass "-lm" to the linker,

Andreas
--
 Andreas Jaeger, Director Platform / openSUSE, aj@...
  SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
   Maxfeldstr. 5, 90409 Nürnberg, Germany
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


attachment0 (199 bytes) Download Attachment

Re: There is no pow()

by beradero :: Rate this Message:

| View Threaded | Show Only this Message

Uhmm.. I understand now.. I have to link to the libm (math). But, why stdio don't need to be linked?

Thanks a lot man! I am new to GCC an GNU/Linux, and you help me a lot!

Andreas Jaeger wrote:
Andreas
--
 Andreas Jaeger, Director Platform / openSUSE, aj@suse.de
  SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
   Maxfeldstr. 5, 90409 Nürnberg, Germany
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126