Problem with function pow ()

2

Can anyone tell me why the following code does not compile?

#include <math.h>

double f(double x){
      return (x - (pow(2,x)));
}
    
asked by anonymous 27.03.2018 / 02:32

1 answer

3

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
    
27.03.2018 / 02:47