首页 > 解决方案 > C中未定义的ARM处理器库问题

问题描述

使用 DAVE 4.4.2(基于 Eclipse 的 IDE)为英飞凌微控制器构建 C 程序我收到此错误:

'Building target: mcu.elf' 
main.c:(.text.ERU0_3_IRQHandler+0x696): undefined reference to `arm_mat_init_f32'
'Invoking: ARM-GCC C Linker'
collect2.exe: error: ld returned 1 exit status

这是我的代码的简化概述。

#include <arm_math.h>
[other included libraries]

void my_function() {
  arm_matrix_instance_f32 M;
  float32_t zeros33[3][3] = {0};

  arm_mat_init_f32( &M, 3, 3, &zeros33);
}
[other defined functions]

int main(void) {
  my_function()
  [other stuff]
}

在标题中,arm_math.h我看到了据说未定义的函数的定义。

void arm_mat_init_f32(
arm_matrix_instance_f32 * S,
uint16_t nRows,
uint16_t nColumns,
float32_t * pData);

我怀疑问题可能在于使用了不正确的数据类型,或者在传递参数时不正确地使用了指针。我试图删除&矩阵变量前面的,但没有成功。同样的思路,我也尝试使用不同的数据类型来定义矩阵数据:float32_tfloat.

查看各种警告和信息消息,我注意到声明旁边有一个arm_mat_init_f32Expected 'float32_t *' but argument is of type 'float32_t (*)[3][3]'。因此,我还尝试传递“正常”变量的地址float32_t zero = 0.0f,并且只是0.0f. 由于未定义的功能,它们仍然导致构建失败。

最后一个观察结果是,如果我右键单击代码中的函数调用,并要求“转到声明”,则会在正确的文件中找到正确的函数。

可能是什么问题呢?

标签: ceclipseundefined-referenceinfineon

解决方案


使用 DAVE 时,解决问题的方法是通过 Project/Add new APP 添加 APP。然后选择 System/CMSIS_DSP,然后按“添加”。该程序需要完全重建。

通过这种方式,DAVE 配置了所有必要的环境变量和链接,以便arm_math包含该库。


推荐阅读