代码之家  ›  专栏  ›  技术社区  ›  raggot

c语言中未定义的arm处理器库问题

  •  1
  • raggot  · 技术社区  · 6 年前

    使用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_t float 是的。

    看着各种警告和信息信息,我注意到在 arm_mat_init_f32 宣言说 Expected 'float32_t *' but argument is of type 'float32_t (*)[3][3]' 是的。因此,我还试图传递“normal”变量的地址 float32_t zero = 0.0f ,而且 0.0f 是的。由于未定义函数,它们仍然导致生成失败。

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

    有什么问题吗?

    1 回复  |  直到 6 年前
        1
  •  1
  •   raggot    6 年前

    使用dave时,问题的解决方案是通过project/add new app添加应用程序。然后选择System/CMSIS_DSP,并按“Add”。这个程序需要完全重建。

    这样,dave配置所有必要的环境变量和链接,以便 arm_math 包括图书馆。