Re: #include <math.h>

From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 11/25/03


Date: 25 Nov 2003 16:46:27 GMT

In <pan.2003.11.25.02.05.07.387424@lightspeed.bc.ca> Kelsey Bjarnason <kelseyb@lightspeed.bc.ca> writes:

>On Mon, 24 Nov 2003 16:52:07 -0800, Darius Fatakia wrote:
>
>> I seem to be having trouble with some of my math functions (pow, sqrt,
>> acos). They're the only ones I use in my code and they prevent the program
>> from compiling. I get a "undefined reference to 'pow'" error. Here is the
>> relevant portion of my code.
>
>Sounds like a linker error - are you linking the math libraries? There's
>a certain, popular compiler, especially widely used in the Linux world,
>which has the terminally brain-dead habit of not including the math
>libraries by default. Assuming you're using this compiler, try something
>like this:
>
>gcc -lm file.c

gcc merely follows the common Unix convention, established by a certain
Dennis M. Ritchie.

Dan

-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de


Relevant Pages

  • Re: OT : Approximate / fast math libraries ?
    ... where math calls are taking more time than I would hope. ... have hardware instructions for trig functions. ... My recollection is that -ffast-math tells gcc to assume error free math. ...
    (Fedora)
  • Re: OT : Approximate / fast math libraries ?
    ... in standard maths functions, like log, exp sqrt etc. ... There are fast math options for gcc. ...
    (Fedora)
  • Re: #include <math.h>
    ... > acos). ... Sounds like a linker error - are you linking the math libraries? ... a certain, popular compiler, especially widely used in the Linux world, ...
    (comp.lang.c)