TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:10849] compiling c code



Mike Hicks wrote:

> > I wrote some code in c but gcc is complaining that there is no function
> > sqrt or pow in the math.h. I looked at math.h but did find what I was
> > looking for is there a different name (function) or header that will
> > compute a power or square root?
>
> You have to link the code with the math library (/lib/libm-*)
>
> To do this, add '-lm' to your compile command
>
> $ gcc source.c  -lm  -o executable
>
> Just so you can understand exactly what's going on, if you had to
> include the MesaGL library (/usr/lib/libMesaGL-*), you would add
> '-lMesaGL'..  basically, just strip off the leading 'lib' from a library
> name..
>
> --
>  _  _  _  _ _  ___    _ _  _  ___ _ _  __   Flirt: A woman who thinks
> / \/ \(_)| ' // ._\  / - \(_)/ ./| ' /(__   it's every man for
> \_||_/|_||_|_\\___/  \_-_/|_|\__\|_|_\ __)  herself.
>  [ Mike Hicks | http://umn.edu/~hick0088/ | mailto:hick0088@umn.edu ]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org

That is what I needed thanks.....
Rodney