我正在尝试为Cortex-M4F构建项目。芯片具有FPU,因此使用-mfpu=fpv4-sp-d16 -mfloat-abi=hard
进行构建,并且为了节省空间不使用任何库,因此使用-nostdlib -fno-builtin
。
现在我想要使用浮点运算,但是这样做时出现链接器错误:
led1642gw_gain.c:(.text.led_calculateGain+0xc): undefined reference to `__aeabi_f2d'
led1642gw_gain.c:(.text.led_calculateGain+0x24): undefined reference to `__aeabi_ddiv'
led1642gw_gain.c:(.text.led_calculateGain+0x36): undefined reference to `__aeabi_dsub'
led1642gw_gain.c:(.text.led_calculateGain+0x48): undefined reference to `__aeabi_ddiv'
led1642gw_gain.c:(.text.led_calculateGain+0x54): undefined reference to `__aeabi_d2f'
led1642gw_gain.c:(.text.led_calculateGain+0x9e): undefined reference to `__aeabi_f2d'
led1642gw_gain.c:(.text.led_calculateGain+0xb6): undefined reference to `__aeabi_ddiv'
led1642gw_gain.c:(.text.led_calculateGain+0xc8): undefined reference to `__aeabi_dsub'
led1642gw_gain.c:(.text.led_calculateGain+0xda): undefined reference to `__aeabi_ddiv'
led1642gw_gain.c:(.text.led_calculateGain+0xe6): undefined reference to `__aeabi_d2f'
led1642gw_gain.c:(.text.led_calculateGain+0x10c): undefined reference to `__aeabi_f2d'
为什么会这样?如果我理解正确,它不应该依赖于库函数,而是使用ARM本地的FPU指令。