cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mdvankar1990
Visitor
Visitor
1,966 Views
Registered: ‎08-09-2017

error while using math.h library in zynq 7000 zc 702 board application programme.

Jump to solution

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??

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ericv
Scholar
Scholar
2,519 Views
Registered: ‎04-13-2015

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

 

View solution in original post

1 Reply
ericv
Scholar
Scholar
2,520 Views
Registered: ‎04-13-2015

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

 

View solution in original post