Re: Simple c program won't compile
On Tue, Mar 06, 2001 at 12:26:30AM +1030, Mark Phillips wrote:
> Hi,
>
> The following program:
>
>
> #include <stdio.h>
> #include <math.h>
>
> int main(int argv, char **argc){
> double x;
>
> x=sqrt(5.0);
> }
>
>
> does not compile. Instead I get the errors:
>
> $ gcc thick.c
> /tmp/ccU9fgSr.o: In function `main':
> /tmp/ccU9fgSr.o(.text+0x16): undefined reference to `sqrt'
> collect2: ld returned 1 exit status
you have to link it with the math lib:
gcc thick.c -lm
^^
Cheers,
Erdmut
--
Erdmut Pfeifer
science+computing gmbh
-- Bugs come in through open windows. Keep Windows shut! --
Reply to: