Re: Newbie: gcc can't link with math.h functions?


Subject: Re: Newbie: gcc can't link with math.h functions?
From: Jim Cole (greyleaf@yggdrasill.net)
Date: Sat Nov 03 2001 - 22:26:31 MST


Hi - You need to explicitly link the math library. Try

  gcc test.c -o test -lm

Jim

Benoit Nadeau's bits of Sat, 3 Nov 2001 translated to:

>OK. This is weird.
>I have this:
>
>#include <stdlib.h>
>#include <stdio.h>
>#include <math.h>
>
>int main(int argc, char **argv)
>{
> printf("%f", ceil((double)(1.3)));
> return 0;
>}
>
>Then, I enter "gcc test.c -o test", and it gives me this output:
>/tmp/ccHB40rg.o: In function `main':
>/tmp/ccHB40rg.o(.text+0x24): undefined reference to `ceil'
>/tmp/ccHB40rg.o(.text+0x24): relocation truncated to fit:
>R_PPC_REL24 ceil
>collect2: ld returned 1 exit status
>
>I'm using YDL 2.0 and I have the 2.95.3-2u gcc packages.
>What should I do? (apart from downloading new versions of
>gcc, unless you know a place other than linuxppc.org,
>because its ftp site is down)
>
>(P.S.: I'll have to re-subscribe tomorrow with a *@mac.com
>address, but I'm the same guy)
>
>Thanks,
>
>- Benad
>
>



This archive was generated by hypermail 2a24 : Sat Nov 03 2001 - 22:39:04 MST