cancel
Showing results for 
Search instead for 
Did you mean: 

SQRT in stm32f4 ?

bmwael1
Associate II
Posted on June 03, 2013 at 15:06

Hello

I want to use sqrt (

square root

) function to calculate sqrt (x^2 + y^2)

but i haven't math.h in my root this is the error

 

undefined reference to `sqrt'

 

collect2: ld returned 1 exit status

how can i fix it please or are there an approximation of this function.

Thanks 🙂

#lmgtfy
1 REPLY 1
Posted on June 03, 2013 at 15:34

Include files don't pull in code, you must link against a suitable C math library. Consider using the ''-lm'' option for the compiler, which should pull in libm

Also consider sqrtf(), this at least might have some chance of using the FPU.

http://www.embedded.com/electronics-blogs/programmer-s-toolbox/4219659/Integer-Square-Roots

Might I also recommend Google or Bing as an effective tool for discovering the wealth of information on the internets.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..