08-09-2017 12:50 AM
hi guys,
I m trying to simple program.
#include <stdio.h>
#include <math.h>
#include "platform.h"
int main()
{
float a,b,c,d;
a=2.3;
b=2.5;
c=a+b;
d=cosf(c);
}
in this i am getting "undefined reference to cosf ".
in this function,
instead of using variable c, if i use some value it gets run.
like cosf(2.5);
but using variable gives above error.
solution??
08-09-2017 05:29 AM
You need to link with the math library,
In the linker setting, add "m" (without the quotes) in the library window.
The reason it works when you put a constant is the compiler replaces cosf(2.5) by the resulting value.
Regards
08-09-2017 05:29 AM
You need to link with the math library,
In the linker setting, add "m" (without the quotes) in the library window.
The reason it works when you put a constant is the compiler replaces cosf(2.5) by the resulting value.
Regards