From: Colm Buckley (colm at domain tuatha.org)
Date: Wed 14 Apr 1999 - 15:14:09 IST
> I have included math.h, I have even searched to see if I was including
> the wrong one, but I can't find another.
>
> So could anyone please tell me why I get when I compile:
> [phil at domain jalapeno src]$ gcc mathtest.c
> /tmp/ccVM9ceB.o: In function `main':
> /tmp/ccVM9ceB.o(.text+0x38): undefined reference to `sqrt'
> /tmp/ccVM9ceB.o(.text+0x6b): undefined reference to `sqrt'
> collect2: ld returned 1 exit status
sqrt() is in the maths library "libm.so". Add the "-lm" flag to gcc to
tell it to link with this library.
gcc -o mathtest mathtest.c -lm
Colm
-- Colm Buckley B.A. B.F. <colm at domain tuatha.org> | <colm.buckley at domain cs.tcd.ie> Department of Computer Science # +353 87 2469146 # whois cb3765 Trinity College, Dublin 2, Ireland. # http://www.tuatha.org/~colm/ Nothing is foolproof to a sufficiently talented fool.
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:07 GMT