3
Would someone tell me why the following code does not compile?
#include <math.h>
double f(double x){
return (x - (pow(2,x)));
}
3
Would someone tell me why the following code does not compile?
#include <math.h>
double f(double x){
return (x - (pow(2,x)));
}
5
Compile, compile. But not linka because the mathematical library was not added to the build of executable.
The library referenced by the header math.h
is not linked by default like other basics, because it can change according to the platform, and you have to say that you want it to be used in the process of build, then put this in the compiler command line:
-lm
It worked, that’s right, thank you
Browser other questions tagged c compilation library
You are not signed in. Login or sign up in order to post.
Which error?
– Jefferson Quesado
undefined reference to `Pow'
– Eduardo Stefanello
How is the code running? How was it compiled ? If it was through an IDE, what was it ? If it was compiled by hand, include the command you used
– Isac
This is a link error, I imagine, due to the message. It’s not build. Try compiling with the option
-c
if using GCC (I believe ICC also follow the same flags)– Jefferson Quesado