gcc and math.h

Marc Schwartz MSchwartz at MedAnalytics.com
Mon Mar 22 01:17:22 UTC 2004


On Sun, 2004-03-21 at 18:36, stucklenp wrote:
> Kind persons:
> 
> I routinely program using C and compile with gcc.  My problem is that I need
> some math log functions--ln, log10, and log2--and these functions are not
> included in math.h from what I can determine.  Can anyone suggest how I can
> get these functions?
> 
> I have tried notes to the glibc groups and not received any replies.
> 
> Thanks.
> 
> Paul


You need to add '-lm' as an argument to the gcc command line in order to
link in the math library.

For example:

gcc -O -o myprog myprog.c -lm

If you are unsure of the required header file, you can usually type
something like:

man log

at the command line.

HTH,

Marc Schwartz






More information about the fedora-list mailing list