Skip to main content
bmwael1
Associate III
June 3, 2013
Question

SQRT in stm32f4 ?

  • June 3, 2013
  • 1 reply
  • 2786 views
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
    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    June 3, 2013
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..