List Info

Thread: Undefined reference to 'fmod'




Undefined reference to 'fmod'
user name
2006-06-11 04:35:49
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.  This makes me very frustrated :(  Thanks very much
in advance.

James
-
To unsubscribe from this list: send the line
"unsubscribe linux-c-programming" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html
Undefined reference to 'fmod'
user name
2006-06-11 07:17:46
On 6/11/06, James Colannino <jamescolannino.org> 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.

Use the -lm switch to link against libm.a (the math
library).

	\Steve
-
To unsubscribe from this list: send the line
"unsubscribe linux-c-programming" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html
Undefined reference to 'fmod'
user name
2006-06-11 07:18:30
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 <glynngclements.plus.com>
-
To unsubscribe from this list: send the line
"unsubscribe linux-c-programming" in
the body of a message to majordomovger.kernel.org
More majordomo info at  http://vge
r.kernel.org/majordomo-info.html
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )