[prog] Programming questions (Re: [Newchix] Another problem learning C)

Mary Gardiner mary-linuxchix at puzzling.org
Mon Apr 5 08:24:14 EST 2004


Since this list is for newchix questions about Linux systems you may be
better off asking the programming list (Cc-ed).

-Mary

On Sun, Apr 04, 2004 at 09:58:07PM +0100, David Sumbler wrote:
> When I compile a program (taken from "Beginning Linux Programming") with
> 
> gcc -o limits limits.c
> 
> I get an error message.  I have stripped out everything non-essential
> from the program for the purposes of this message, so the program now
> reads:
> 
> #include <sys/types.h>
> #include <sys/resource.h>
> #include <sys/time.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <math.h>
> 
> int main()
> {
>     double x = 4.5;
>     x = log(x*x + 3.21);
> }
> 
> The error message I get (as with the full program) is:
> 
> /tmp/ccaYPoJy.o(.text+0x39): In function `main':
> : undefined reference to `log'
> collect2: ld returned 1 exit status
> 
> Can anybody explain why this is?
> 
> I am using gcc 3.3.2
> 
> Incidentally, the program as downloaded had the <math.h> line missing,
> although it is included in the listing in the book.
> 
> David
> 
> -- 
> _______________________________________________
> Newchix mailing list
> Newchix at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/newchix


More information about the Programming mailing list