Re: Simple c program won't compile
I've just solved my own problem. Of course I needed to do
$ gcc thick.c -lm
It's been a while since I've used C. Sorry for the silly question.
Cheers,
Mark.
Mark Phillips [mark@infoeng.flinders.edu.au] 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
>
>
> What is wrong?
>
> Thanks,
>
> Mark.
>
> --
> _/~~~~~~~~\___/~~~~~~\____________________________________________________
> ____/~~\_____/~~\__/~~\__________________________Mark_Phillips____________
> ____/~~\_____/~~\________________________________mark@ist.flinders.edu.au_
> ____/~~\HE___/~~\__/~~\APTAIN_____________________________________________
> ____/~~\______/~~~~~~\____________________________________________________
> __________________________________________________________________________
> "They told me I was gullible ... and I believed them!"
>
--
_/~~~~~~~~\___/~~~~~~\____________________________________________________
____/~~\_____/~~\__/~~\__________________________Mark_Phillips____________
____/~~\_____/~~\________________________________mark@ist.flinders.edu.au_
____/~~\HE___/~~\__/~~\APTAIN_____________________________________________
____/~~\______/~~~~~~\____________________________________________________
__________________________________________________________________________
"They told me I was gullible ... and I believed them!"
Reply to: