Undefined ARM processor library issue in C

960 Views Asked by At

Building a C program for an Infineon microcontroller using DAVE 4.4.2 (an IDE based on Eclipse) I get this error:

'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

This is a simplified overview of my code.

#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]
}

While in the header arm_math.h I see the definition of the function which is said to be undefined.

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

What I suspected is that the issue might have lied in the incorrect data type being used, or the incorrect use of pointers in passing the arguments. I tried to remove the & in front of the matrix variables, but unsuccessfully. On the same line of thinking, I also tried to use different data types for the definition of the matrix data: float32_t and float.

Looking at various warnings and info messages, I noticed one next to the arm_mat_init_f32 declaration saying Expected 'float32_t *' but argument is of type 'float32_t (*)[3][3]'. I therefore also tried to pass the address of a "normal" variable float32_t zero = 0.0f, and just 0.0f. They both still resulted in the build to fail due to the undefined function.

A last observation is that if i right-click the function call in my code, and ask to "go to Declaration", the right function is found, in the right file.

What could be the problem?

1

There are 1 best solutions below

0
On BEST ANSWER

When using DAVE, a solution to the problem is adding an APP via Project/Add new APP. Then select System/CMSIS_DSP, and press "Add". The program needs to be fully rebuilt.

In this way, DAVE configures all necessary environmental variables and links so that the arm_math library is included.