Link error passing double variable to sqrt function
Hi
I’m working on Linux and get the same linker error when math.h is included and a function of libmath is used.
Not all functions from libmath trigger the linker error but sqrt() in any case. I’m using plain C.
EDIT Like in this example the error was only triggered if the value of the argument was not known at compile time.
The IDE automatically sets Project->Properties->C/C++ Build->Settings->MCU GCC Linker->Libraries button “Use C math library (-lm) checked
My solution found elswere is:
Goto Project->Properties->C/C++ Build->Settings->MCU GCC Linker->Libraries and uncheck this button “Use C math library (-lm)
Then click on add and type “m”.
The explanation for this found elsewere shall be: the order of linking libc and libmath is is reversed with default setting.
Dieter