Undefined reference to a math function
Posted: Mon Oct 26, 2015 4:54 am
I am new to C programming and I 've started a simple project in Eclipse.
I can't compile my project that uses a atan2 function.
my code looks like this (I 've added #include <math.h>) :
The error is
/user_main.c:70: undefined reference to `atan2'
If for example I set :
it compiles ok.
I 've searched some other forums about this and they say it's a linker error and the solution is to add -lm to linker options.
Where is the correct place to add this option ?
I can't compile my project that uses a atan2 function.
my code looks like this (I 've added #include <math.h>) :
Code: Select all
double avgWindDir;
double a=sumEastWest;
double b=sumNorthSouth;
avgWindDir = atan2(a, b);
The error is
/user_main.c:70: undefined reference to `atan2'
If for example I set :
Code: Select all
double a=1;
double b=2;
it compiles ok.
I 've searched some other forums about this and they say it's a linker error and the solution is to add -lm to linker options.
Where is the correct place to add this option ?