
math problem
Im writting a math program to calculate the area below a curve. Everything seems to be fine only that in the following funcion:
float y(float x) {
float y;
/* 1
y = 
exp(x^2)
*/
/* y = 1 / fabs(exp(x*x));*/
y= 1/fabs(exp(x*x));
return y;
}
I get this error when I compile it (gcc 2.95.3) on linux 2.4.18:
/tmp/ccvlcwTt.o: In function `y':
/tmp/ccvlcwTt.o(.text+0x5e): undefined reference to `exp'
Thanks for your help

Did you: #include <math.h>
I presume you're trying for this function.

Quote:
Originally posted by Hammer
Did you: #include <math.h>
I presume you're trying for this function.
the error is in the linker phase, which means its not a problem that can be fixed by #including a .h; you need to link against the math library.

Yes, I included math.h, otherwise I would get another kind of error when compiling

It's a problem with the linking phase, as told by moi. Compile your program like:
cc file.c lm
where lm tells the compiler to look up the Maths Library too for functions, in your case, which is the exp() function to be looked for.