Skip to main content

Thread: Why doesn't my gcc recognize math.h in subroutines?


hello of you.
trying develop little calculus application , gcc giving me problems math.h.
if try compile this:

#include <stdio.h>
#include <math.h>

int main(void) {
printf("\n exp(1)=%lf", exp(1.0));
}
i find no problems. if write down this:
#include <stdio.h>
#include <math.h>

double result(double x);

int main(void) {
printf("\n exp(1)=%lf", result(1.0));
}
double result(double x) {
return exp(x);
}
it doesn't work, giving error " undefined reference 'exp' ".

maybe noob mistake, wonder why happens.

i found link. hope it's of use mate:
http://www.linuxforums.org/forum/lin...math-h-lm.html

edit: in fact try putting 1.0 in exp function rather passing in x variable quick test. post #7 looks quite informative.


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Why doesn't my gcc recognize math.h in subroutines?


Ubuntu

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code