I have a small bit of code:
#include <math.h>
int main(void){
pow(2.0,7.0);
//Works
double x = 3.0;
pow(2.0,x);
//Fails with error "undefined reference to 'pow'"
return 0;
}
I have linked -lm
in my Eclipse compiler settings: gcc -O0 -g3 -Wall -lm -c -fmessage-length=0 -MMD -MP -MF"src/pgm.d" -MT"src/pgm.d" -o "src/pgm.o" "../src/pgm.c"
, so I'm not sure what the source of the error is. What am I not doing corectly?