> 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 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 Buckley B.A. B.F. <colm at tuatha.org> | <colm.buckley at 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.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!