最近Nuttx系统中编译自定义的应用,程序中使用了一些常用的数学函数,在进行编译时,报错:
arm-none-eabi-ld: /xxx/apps/examples/xxx.c:424: undefined reference to `sin'
arm-none-eabi-ld: /xxx/apps/examples/xxx.c:425: undefined reference to `cos'
arm-none-eabi-ld: /xxx/apps/examples/xxx.c:426: undefined reference to `sin'
明明程序中都包含了<math.h>的头文件,但就是一直报错,这个问题困扰了好几天,也在网上查找尝试了各种解决方法,均无果。
后来在nuttx中搜索关键词,发现在官方readme.txt文档中有这样一段表述:
math.h
Even though you should not use a foreign C-Library, you may still needto use other, external libraries with NuttX. In particular, you may need to use the math library, libm.a. NuttX supports a generic, built-in math library that can be enabled using CONFIG_LIBM=y. However, you may still want to use a higher performance external math library that has been tuned for your CPU. Sometimes such