Click to See Complete Forum and Search --> : Simpile C Problem


chrisnlynch
04-02-2002, 02:52 PM
I am writing a small program to calculate the area under a curve. I get the following error each time I try to compile:

[chris@localhost Programs]$ gcc areaundercurve.c
/tmp/ccAPP8Ks.o: In function `f':
/tmp/ccAPP8Ks.o(.text+0x15e): undefined reference to `pow'
/tmp/ccAPP8Ks.o(.text+0x173): undefined reference to `sqrt'
collect2: ld returned 1 exit status
[chris@localhost Programs]$

I have include <math.h> so why am I getting these errors?

Thanks,
Chris

chrisnlynch
04-02-2002, 02:54 PM
simpLE :)

debiandude
04-02-2002, 03:00 PM
You may be include in math.h but your not linking the library.

Do this:

gcc prog.c -o prog -lm

the -lm links the math library.