解决在nuttx系统中编译应用程序时缺少math.h的错误

在Nuttx系统中编译应用时遇到包含math.h却报错的问题。通过阅读官方文档发现,需启用内置math库CONFIG_LIBM。将CONFIG_LIBM=y添加到.config文件后,成功解决编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近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     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值