This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Compilation error
- To: "Jose Miguel A.C.Pires" <jmcp at ci dot uminho dot pt>
- Subject: Re: Compilation error
- From: llewelly at 198 dot dsl dot xmission dot com
- Date: Mon, 21 Feb 2000 11:37:57 -0700 (MST)
- cc: help-gcc at gnu dot org
On Mon, 21 Feb 2000, Jose Miguel A.C.Pires wrote:
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Hello
>
> I'm trying to compile this simple program
>
> #include <stdio.h>
> #include <math.h>
>
> int main(void)
> {
> float r=2;
>
> printf("A raiz de %2.0f e' %.6f", r, sqrt(r));
>
> return 0;
> }
>
> but i get the following errors.
>
> /tmp/cca110161.o: In function `main':
> /tmp/cca110161.o(.text+0x17): undefined reference to `sqrt'
>
Add -lm to your link line:
$gcc foo.c -lm
(-lm means 'link libm.[so,a] . libm is the math library.')