Can anyone tell me why the following code does not compile?
#include <math.h>
double f(double x){
return (x - (pow(2,x)));
}
Can anyone tell me why the following code does not compile?
#include <math.h>
double f(double x){
return (x - (pow(2,x)));
}
Compile, compile. But linka because the math library was not added to the build process of the executable.
The library referenced by the math.h
header is not linked by default as other basic ones, why it may change according to the platform, and you have to say that you want it to be used in build process, then put this in the compiler command line:
-lm