This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sdk 1.6.0 Math Function.

Hello,

how add math function to a segger project.

I have included 

#include <math.h>

void myFuncion()

{

. . .

 rx=(int)((float)(*x-cx)* cos(a) -(float)(*y-cy)*sin(a)+cx);

. . .

}

but i get error

undefined reference to 'cos'

Parents
  • Hi,

    The problem is probably that you are using Zephyr's minimal libc implementation, which is missing a lot of features normally present in libc.

    You can change to using the newlib implementation by setting CONFIG_NEWLIB_LIBC=y in your prj.conf file. (Remember that if you are using SES, changes in prj.conf doesn't take effect until you re-open the project or use 'Project -> Run CMake...')

    Note that newlib can also be configured to exclude a lot of features (to save space). This means that you might also have to configure your project to not use newlib-nano, but the full newlib implementation. You can do that by setting CONFIG_NEWLIB_LIBC_NANO=n.

    Best regards,

    Didrik

Reply
  • Hi,

    The problem is probably that you are using Zephyr's minimal libc implementation, which is missing a lot of features normally present in libc.

    You can change to using the newlib implementation by setting CONFIG_NEWLIB_LIBC=y in your prj.conf file. (Remember that if you are using SES, changes in prj.conf doesn't take effect until you re-open the project or use 'Project -> Run CMake...')

    Note that newlib can also be configured to exclude a lot of features (to save space). This means that you might also have to configure your project to not use newlib-nano, but the full newlib implementation. You can do that by setting CONFIG_NEWLIB_LIBC_NANO=n.

    Best regards,

    Didrik

Children
Related