1

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?

raggot
  • 992
  • 15
  • 38
  • 3
    `undefined reference` is a linker error, so I guess you are not correctly linking your executable to the `arm_math` library? – Mike van Dyke Jul 12 '18 at 09:51
  • @MikevanDyke Thanks. I forgot to mention that `arm_math.h` is in the same folder as `main.c`, along with many other header files which are included with no issue. I can't imagine linking problems with this configuration. – raggot Jul 12 '18 at 11:35
  • @MikevanDyke I think you put me on the right track. I now realise the header is in the folder, but not the `.c` file. I'll do some research and update the question in a bit. – raggot Jul 12 '18 at 11:41
  • 1
    Have you tried [these](https://www.infineonforums.com/threads/823-DAVE-TIP-of-the-day-Things-need-to-do-when-use-math-functions) steps? Did you get the DSP lib frmo the [CMSIS repo](https://github.com/ARM-software/CMSIS) or how did you download it? – Mike van Dyke Jul 12 '18 at 11:46
  • @MikevanDyke Thanks for that link. I wasn't able to find something like that. Apart from downloading the latest library, I followed those steps unsuccessfully. I need to be careful with updating the library because I did not initiate this project and am only expanding it. I'm afraid a full update of the libraries might break the existing code (I'm especially scared about things that would compile fine but in particular cases misbehaving in run time in a way C finds acceptable). Once again, you probably put me on the right track. I'll investigate further in this direction. – raggot Jul 12 '18 at 15:30

1 Answers1

1

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.

raggot
  • 992
  • 15
  • 38