Re: Undefined reference to 'fmod'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



James Colannino wrote:

> Hey everyone.  I included the math.h header, proceeded to use fmod(),
> then got the following error:
> 
> /tmp/ccKQxpJi.o: In function `main':
> 04-03-calc.c:(.text+0x144): undefined reference to `fmod'
> collect2: ld returned 1 exit status
> 
> Does anybody know why it won't link?  fmod() is a part of the standard
> library.

No, fmod() is in libm, so you have to add -lm to the link command.

As a general rule, anything which uses <math.h> has to link against
libm.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux