Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 4

Level 4
First like received
Level 4

I am trying to use the "math.h"  library so I can do  pow( double, double) and log10 (double)  functions,

I have tried #include "math.h" and also #include <math.h>  in the main.c file  and when I compile it gives me this error:

C:\Cypress\Projects\Bonding\BLE_Bonding\BLE_Bonding\BLE_Bonding.cydsn/.\main.c:283: undefined reference to `pow'

collect2.exe: error: ld returned 1 exit status

The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

Is this from some kind of tool setting?  I don't know what I did,  this was actually working yesterday, then magically decided to stop and give me compile errors.

I get the same undefined reference error if I try to use the log10() function as well.

just wondering if some how I fat fingered a bad keyboard sequence or did something similar to disable something on the tool, ??   OR did the tool do some kind of autoupdate and break something without my knowledge ( I did not manually update anything)

the source file math.h still exists in the directory: C:\Program Files (x86)\Cypress\PSoC Creator\3.3\PSoC Creator\import\gnu\arm\4.9.3\arm-none-eabi\include

Or did the compile #define Symbols change?  In the math.h file itself there are #defines that possibly are breaking something?

1 Solution
Level 4
First like received
Level 4

from another thread, I found this and tried it and it is the correct answer:

In Creator go to Project -> Build Settings -> Linker -> General


Add "m" (without the quotes) into Additional Libraries. This will add the math library "Libm.a" to your project.

View solution in original post

2 Replies