Using Math Functions in PSoC® Creator™ for the PSoC 4 or PSoC 5LP GCC Compiler – KBA93076

Version 2

    Version: **

     

    Translation - Chinese: 如何在PSoC® Creator™中为PSoC 4或PSoC 5LP GCC编译器使用数学函数 - Community Translated (ZH)

     

    Question: How do you use math functions in PSoC® Creator™ 3.0 for the PSoC 4 or PSoC 5LP GCC Compiler?

     

    Answer:

    To use math functions (for example, sqrt or pow) with PSoC Creator, do the following steps:

    1.   Click Project.
    2.   Click Build Settings.
    3.   Open the Linker settings under ARM GCC 4.7.3 and click General.
    4.   Under Additional Libraries, add m.

    These steps are shown in Figure 1.

    Figure 1. Adding the Math Library

    Math library

    If you do not add this additional library then you will get the build error, "undefined reference to sqrt" (where sqrt is a math function) if you try to use a math function.